• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am a beginner and this might be an absurd question......and so friends kindly bear with me..requesting ur help in this case

In a class it is said that main() is a thread...why dont we implement the Runnable() interface or extend the Thread class for it?
 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Badri

It is surely not an absurd question as u mentioned

When ever we create a java program one thread called main is created
but it is not in your control. it is in full control with JVM.
The thread "Main" runs in JVM.so no need to extend the Thread class or implement Runnable

If U are creating u'r own thread then u need to extend Thread or implement Runnable.
If u do so thread will be on u'r control

we can say that the thread main is not in the control of the programmer
It is with the control of JVM

Hope U Got it!
 
badrinarayanan
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi srihari

Thanks for ur answer and one more question...is it possible to get any information about the main thread
 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can get reference to the main thread by calling Thread.currentThread().
Now you can work with it as with any other therad.
For example you can dumpStack().
 
We're being followed by intergalactic spies! Quick! Take this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic