• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Another One from Threads...

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

So whats the answer of this one...I thought it to be A and C but as per mocks the only correct answer is A.As per my understanding after starting a new thread, the main thread will stop and as a result, all other threads associated with main thread also stops.. am i right? or is it only the daemon threads that stops when main stops executing.
 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what happens is that start() asks Virtual Machine to start a new thread and returns *immediately* without waiting for the new thread to be created/started/etc/
That's right - only A is correct.
[ September 22, 2003: Message edited by: Andris Spruds ]
[ September 22, 2003: Message edited by: Andris Spruds ]
 
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

is it only the daemon threads that stops when main stops


Yes
 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Harjinder:
Sounds like you've got it, but this wording is worrisome: is it only the daemon threads that stops when main stops.
There's nothing special about the "main" thread. The VM quits when there are no more non-daemon threads alive. Non-daemon threads are called "user" threads. So you could rephrase with something like: it is only user threads that keep the VM running.
 
Amateurs built google. Professionals built the titanic. We can't find the guy that built this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic