I have one thread that is needed to be used multiple times. I dont want to create multiple instnces of this thread but I would like it to be used multiple time by another class.
Here's my code:
public class Restaurant
{
public static void main(String args[])throws InterruptedException
{
int i=0;
final int NUMTHREADS = 3; // number of threads
Customer thr[] = new Cutomer[NUMTHREADS];
Thread myThread[] = new Thread[NUMTHREADS];
Waiter r_thr = new Waiter();
Thread rThread = new Thread(r_thr);
rThread.start();
// create threads
for( i = 0; i < NUMTHREADS; ++i )
{
thr[i] = new Customer(i);
myThread[i] = new Thread( thr[i] ); // eah array hold an instance of sem1
myThread[i].start(); // start the thread
}
}
}
As of now, my waiter thread runs once and quits. I want it to run multiple times ( in this case, 3 times).
Any help would be appreciated.

New Topic/Question
Reply



MultiQuote




|