Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Another One from Threads...

 
Harry Singh
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
  • 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.
 
Andris Spruds
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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 ]
 
Barkat Mardhani
Ranch Hand
Posts: 787
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it only the daemon threads that stops when main stops

Yes
 
Steve Lovelace
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic