|
Java™ by example!
|
|
|
How do I get the state of a thread (running, blocked, etc)?
This becomes very simple with the new java.lang.management package in JDK 1.5. The following example starts up a Task thread and a Monitor Thread. The Monitor thread prints out the state of the Task thread every half a second. All possible thread states are documented in the API docs. Main.java:
outputs:
Further Information
Author of answer: Joris Van den Bogaert
Comments to this answer are only viewable by members. Login or become a member!
|
|
|
|
|