The application example for this procedure creates two threads in the main()
method and displays output to a JVIEW console window. This procedure refers to code created in the Multithreaded Beverages Application. If you’d like to create this project to complete the following exercises, do so now. You may also use the following procedures to suspend and resume the threads of any multithreaded application.
To suspend a thread
System.out.println("I Like Coffee" + " " + i);
— and —
in the Tea class on the following statement:
System.out.println("I Like Tea" + " " + i);
Note The operating system will ultimately determine the processing order of the threads in a given application unless there are statements in the code to specify conditions under which to create and run a new thread.
Notice the Suspension Count for Thread-1 changes from 0 to 1.
If you are using the application created for this procedure, you’ll see that only the output from the non-suspended thread appears in JVIEW’s console window.
At some point in the debugging of a multithreaded application you may want to re-start the suspended thread. Follow these steps to resume a suspended thread:
Note This procedure requires that you have:
To resume a suspended thread
Notice the Suspension Count for Thread-1 changes from 1 to 0.