Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

start join start

Thread view: 
Ravi - 06 Mar 2007 17:32 GMT
Can you please tell why the following code snippet gives me error
IllegalThreadStateException

n1 = new Thread(......//
n2 = new Thread(......//
..
//
n1.start();
n2.start();

n1.join();
n2.join();

n1.start();
n2.start();

...
Eric Sosman - 06 Mar 2007 17:54 GMT
Ravi wrote On 03/06/07 12:32,:
> Can you please tell why the following code snippet gives me error
> IllegalThreadStateException
[quoted text clipped - 11 lines]
> n1.start();
> n2.start();

   Because a Thread can only be started once.  Read the
Javadoc.

Signature

Eric.Sosman@sun.com

Ravi - 07 Mar 2007 07:09 GMT
>     Because a Thread can only be started once.  Read the
> Javadoc.
>
> --
> Eric.Sos...@sun.com

but can we stop and then start it again.any work around for it
Thomas Schodt - 07 Mar 2007 07:23 GMT
>>     Because a Thread can only be started once.  Read the
>> Javadoc.
[quoted text clipped - 3 lines]
>
> but can we stop and then start it again.any work around for it

Tell us what you are trying to accomplish.

Is there a reason for not using new Thread() again?

[A workaround would be; don't allow the thread to complete in the first
place.]
Patricia Shanahan - 07 Mar 2007 09:47 GMT
>>     Because a Thread can only be started once.  Read the
>> Javadoc.
[quoted text clipped - 3 lines]
>
> but can we stop and then start it again.any work around for it

You have two options:

1. Use some form of coordination other than join, so that each thread
does not terminate until it has done all its work.

2. Create new threads to do the post-join tasks.

Patricia


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.