vanuatu
02-19-2003, 04:22 PM
If I created a subclass called testThread, put a counter in it that increments every 100 milliseconds, and add a public method to retrieve the counter value, would the following be correct?
class clockThread extends Thread {
int counter = 0;
public clockThread(int number) {
while(true) {
counter = number;
try {
Thread.sleep(100);
}
catch ( InterruptedException e) {}
counter ++
}
}
}
How would I create an applet that has two instances of testThread and uses the paint method to display the counters in two threads? How would I adjust the priorities of the two threads?
Your help in understanding this will be appreciated.
class clockThread extends Thread {
int counter = 0;
public clockThread(int number) {
while(true) {
counter = number;
try {
Thread.sleep(100);
}
catch ( InterruptedException e) {}
counter ++
}
}
}
How would I create an applet that has two instances of testThread and uses the paint method to display the counters in two threads? How would I adjust the priorities of the two threads?
Your help in understanding this will be appreciated.