• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

Thread.start()

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why we cannot call start() method more than one time ? After completion of run method we can use the Thread object as a normal object but we cannot call start() method ? can anybody explain the reason behind this ?
 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because you can not call a thread which is already died!!!
After completion of the run method, the thread state will be died. so, you can not again make it(thread process) work.
you use it as normal object.
 
author
Posts: 23928
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by chinnikrishna bulusu:
Because you can not call a thread which is already died!!!
After completion of the run method, the thread state will be died. so, you can not again make it(thread process) work.
you use it as normal object.



Yes, this is correct. There are many internal bookkeeping related to the underlying thread itself, that won't work correctly after the thread has finished.

As for why the designers didn't provide some sort of restart mechanism, which will basically "reconstruct" the object, and start a new thread, you will probably have to ask the Sun engineer that designed it. IMHO, I think they did it correctly. If you want another thread, you should construct another one.

Henry
 
I've been selected to go to the moon! All thanks to this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic