Saturday, 10 June 2017

Java Tutorial : Java Threads (Thread start twice) ~ foundjava


Click here to watch in Youtube :

Click the below Image to Enlarge
Java Tutorial : Java Threads (Thread start twice) 
DisplayThread.java
class DisplayThread extends Thread
{

    public static void main(String args[])
    {
        DisplayThread displayThread = new DisplayThread();

        displayThread.start();
        displayThread.start();
    }

    public void run()
    {
        System.out.println("Hello by = " + this.getName());
    }

}
Output
Hello by = Thread-0
Exception in thread "main" java.lang.IllegalThreadStateException
    at java.lang.Thread.start(Thread.java:705)
    at DisplayThread.main(DisplayThread.java:9)

Click the below link to download the code:

CLICK HERE

No comments:

Post a Comment