• 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
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Confustion in threads again !

 
Ranch Hand
Posts: 124
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Which of the followidng statements are true.
a.All the threads created in a class come to an end at the same time.
b.You can stop a thread indefinitely if u wish to.
c.You can start a thread only by extending the Thread class d.multiple threads accessing a method will lead to producing junk.
e.JVM exits after the main() thread is exited even if there might be some threads running
Is 'd' right or wrong ?
I think the right answers are : b, e
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
e. is wrong. JVM usually exits only when all user threads finish.
d. multiple threads accessing a method will lead to producing junk
is ambiguous.
You can say that multiple threads accessing a method of the same object might produce junk (unpredictable results) if no proper synchronization is done
 
Ranch Hand
Posts: 477
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that B is ambiguous too, because you can stop a thread with interrupt if you have it sleeping or waiting (correct me if I am wrong)
About e: Look at the setDaemon definition.: the JVM finishes when there are non Daemon threads not running. Threads that are non Daemon are called user threads.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic