Java-IsAlive and Join Methods

IsAlive and Join Methods As mentioned, often you will want the main thread to finish last. In the following program, this is accomplished by calling sleep( ) within main( ), with a long enough delay to ensure that all child threads terminate prior to the main thread. Program However, this is hardly a satisfactory solution, … Read more…

Java-Thread Priority

Thread Priority We can assign different priorities to the threads defined in a program by using the setPriority( ) method. When we invoke this method, we have to pass a priority parameter to it. The priority parameter always takes a value between 0 and 10. One of the three static constants in the Thread class, … Read more…

Java-Get Main Thread Reference

Get Main Thread Reference When a Java program starts up, one thread begins running immediately. This is usually called the main thread of your program, because it is the one that is executed when your program begins. The main thread is created automatically when your program is started, it can be controlled through a Thread … Read more…

Java-Stopping Thread

Stopping Thread Whenever we want to stop a thread from running further, we may do so by calling its stop( ) method. This method causes the thread to move to the dead state. A thread will also move to the dead state automatically when it reaches the end of its method. The stop( ) method … Read more…