Thursday 19 January 2017

Java Tutorial: Java Threads (How to get the Thread state)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=9zR-rN1hPIc&list=UUhwKlOVR041tngjerWxVccw

Click the below Image to Enlarge
Java Tutorial: Java Threads (How to get the Thread state) 
MyRunnable.java
public class MyRunnable implements Runnable
{
    public void run()
    {
        /*
         * Returns the state of this thread.
         */
        Thread.State state = Thread.currentThread().getState();
        System.out.print("Thread Name = " + Thread.currentThread().getName());
        System.out.println(" , state = " + state);
    }
}
ThreadDemo.java
public class ThreadDemo
{

    public static void main(String args[])
    {
        Thread t = new Thread(new MyRunnable());
        // this will call run() function
        t.start();
    }
}
Output
Thread Name = Thread-0 , state = RUNNABLE

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/ThreadDemo_state_App.zip?attredirects=0&d=1

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/4a03b5014bb513b61dfa414428ea9747b1421899/BasicJava/ThreadDemo_state_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