Multi Threading
2 posts in topic
Flat View  Flat View

Posted By:   VV_VV
Posted On:   Monday, July 2, 2001 02:34 PM

Hi, I am trying to implement a multi threaded program with the number of threads specified from the command line. The way I am doing is to have all the Thread objects in a vector in a for loop and call the start method of each Thread object. Now the Error I am getting is IllegalThreadStateException. The reason for that I think is, I am trying to start a Thread when there is already another Thread running with the same name. Any work around for that ?


Re: Multi Threading

Posted By:   Shaun_Hicks  
Posted On:   Thursday, July 5, 2001 12:52 PM

One thing to try is a System.out on each thread. The toString() on each thread launched should be a unique id without you having to do anything. If duplicates are somehow happening, then do the manual naming schema as proposed above.

Also, you are joining all the threads in the vector before exiting the application, aren't you ?

Re: Multi Threading

Posted By:   Alex_Chaffee  
Posted On:   Monday, July 2, 2001 07:03 PM

"Doctor, it hurts when I do this."

"So don't do that!"

Just name your threads something different. E.g.

for (int i=0; i<10; ++i) {
new MyThread("my thread " + i).start();
About | Sitemap | Contact