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

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.
 
a fool thinks himself to be wise, but a wise man knows himself to be a fool - shakespeare. foolish tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic