Try This 11-2 Using the Main Thread
All Java programs have at least one thread of execution, called the main thread, which is given to the program automatically when it begins running. So far, we have been taking the main thread for granted. In this project, you will see that the main thread can be handled just like all other threads.
1. Create a file called UseMain.java.
2. To access the main thread, you must obtain a Thread object that refers to it. You do this by calling the currentThread( ) method, which is a static member of Thread. Its general form is shown here:
static Thread currentThread( )
This method returns a reference to the thread in which it is called. Therefore, if you call currentThread( ) while execution is inside ...