• Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads Confusion

 
Mark Henryson
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which of the followidng statements are true.

1. All the threads created in a class come to an end at the same time.
2. You can stop a thread indefinitely if u wish to.
3. You can start a thread only by extending the Thread class
4. Multiple threads accessing a method will lead to producing junk.
5 .JVM exits after the main() thread is exited even if there might be some threads running

Please someone give the correct answers and why it is so?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only vaguely true statement is #2 (although it's also not proper English so by definition its truth value is undefined.) A thread can call, for example, wait() on a local object, and thus pause indefinitely (meaning until some other thread interrupts it or the program exits.) The rest are, well, just not true. #4 would only be true if it said "may lead" rather than "will lead."
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
5 could be true if the remaining threads are all daemon threads.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24213
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to the Threads forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!