...

View Full Version : Threads in Java



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.

Borgtex
02-19-2003, 04:46 PM
Java!=Javascript.
Try to put this message in the "Computer Programming" Forum

vanuatu
02-19-2003, 07:29 PM
Well, thanks for the reply; but .... I do not have permissions to move this thread. Can the administrator help by moving this thread to Computer Programming? If any one in this forum has a solution to the initial question, that would be great.

Thanks.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum