Forums Register Login

start the thread

+Pie Number of slices to send: Send
Hi Friends,


We can start thread two times ?is it posible?How can do?


Thanks&Regards
srinivas
+Pie Number of slices to send: Send
This is what the javadoc of start method says:


It is never legal to start a thread more than once. In particular, a thread may not be restarted once it has completed execution.

Throws:
IllegalThreadStateException - if the thread was already started.



It is always recommended to RTFM (Read the f#$%ing manual)
+Pie Number of slices to send: Send
Here's what you can do instead. Put your code in a Runnable and run it on two threads:

See how we executed the run() method in MyRunnable twice? Is that the effect you wanted? If so, we can also do some neat stuff with Thread pools.
[ September 12, 2007: Message edited by: Stan James ]
+Pie Number of slices to send: Send
threads are same as human beings
they take birth once and die once
we never take birth twice
same is the case with threads
once the thread is started the thread can't be started again
even after the thread finishes executing and reaches dead state
start() can't be called on the dead thread
like once humans are dead,they can't be made alive
if you try to start the same thread again,you will get a IllegalStateException
+Pie Number of slices to send: Send
 

Originally posted by paritosh ranjan:
threads are same as human beings
they take birth once and die once



Have you never seen Dawn (or Shaun) of the Dead?!
+Pie Number of slices to send: Send
what does that mean??
+Pie Number of slices to send: Send
Have a look at the wikipedia articles on Dawn of the Dead and its comedy counterpart, Shaun of the Dead and you will understand what this all means: poor joke.
WARNING! Do not activate jet boots indoors or you will see a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1084 times.
Similar Threads
problems posting
Does this program end?
how to "control" the sequence of two threads ?
Welcome!
Testing
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 09:43:59.