(1) Inherit a class from thread, and (overload) overwrite the Run () method. Within run (), print out a message and call sleep (). Repeat these actions three times, and then return from Run (). Place a startup message in the builder and overwrite finalize () to print a closing message. Create a separate thread class that calls System.GC () and System.runfinalization () within run () and prints a message indicating that the call was successful. Create these two types of threads, and then run them to see what happens.
(2) Modify the Counter2.java to make the thread an internal class and do not need to explicitly save one that points to Counter2.
(3) Modify the Sharing2.java and add a synchronized (synchronized) block inside the Twocounter run () method instead of synchronizing the entire run () method.
(4) Create two thread subclasses, the first run () method is used for the start start, and the handle of the second thread object is captured, and then the Wait () is invoked. Run () of the second class should call Modifyall () for the first thread in a few seconds, so that the first thread can print out a message.
(5) in the Ticker2 Counter5.java, delete the yield () and explain the result. Replace yield () with a sleep () and explain the results.
(6) In Threadgroup1.java, replace the call to Sys.suspend () with a wait () call to the thread group for 2 seconds. In order to obtain the correct result, the object lock of Sys must be obtained within a synchronized block.
(7) Modify the Daemons.java so that main () has a sleep () instead of a readline (). Experiment with different sleep times and see what happens.
(8) to the 7th chapter (the middle section) to find the Greenhousecontrols.java example, it should be composed of three documents. In Event.java, the event class is built on the monitoring of time. Modify this event to make it a thread. The rest of the design is then modified so that they work in concert with the new, thread-based event.