Wednesday 14 December 2016

Java Tutorial : Java Threads (Thread start twice)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=s7rN69ttS0w&list=UUhwKlOVR041tngjerWxVccw

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:
https://sites.google.com/site/ramj2eev1/home/javabasics/ThreadDemo_start_twice_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ThreadDemo_start_twice_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/7d3f471503184934dd2cdb3cf35260480f18e932/BasicJava/ThreadDemo_start_twice_App/?at=master

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment