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) |
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); } }
public class ThreadDemo { public static void main(String args[]) { Thread t = new Thread(new MyRunnable()); // this will call run() function t.start(); } }
Thread Name = Thread-0 , state = RUNNABLEClick 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:
No comments:
Post a Comment