HW3: Using Threads
Due: Tue, March 9, 2004 (Before class time)
[10 points]
-
Define a class, say HW3Thread, extending the Thread class.
The class should take a JTextArea type as one of the arguments
for the construtor.
- In the main applet, create say, three JCheckBox's and three
JTextArea's. Use arrays. Also, create three threads of the above
class. Hint: Do not start the threads in the init() method.
Add ActionListeners to the checkboxes just like the buttons.
In the actionPerformed method, you can call the boolean method
isSelected() on a JCheckBox to see if it is selected or not.
- When the checkbox is selected, the corresponding thread would
print some lines in its associated TextArea. When the checkbox is unselected, the corresponding thread will be in a pause mode, and resume when the checkbox is again selected.
- Look at the documentation for java.lang.Thread class, and do not use the deprecated methods like suspend, resume, etc. Also, the threads should not be in a busy loop mode. Make use of wait and notify.
Click here to see the applet in action