Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

questions on Thread

 
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
found this in a mock test lease answer the 3 questions
A demon Thread group
1 has only demon threads.
2 can have non demon threads.
3 does not exist after all non demon threads in the group have finished executing.
4 does not exist after all the threads in the group have finished executing.
----------------------------------------------
Assume that th is an instance holding a thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.
True
False
---------------------------------------------
A class has 2 synchronized methods, one being static and other non-static.
which one is correct:
The class wide lock and the instance lock being independent of each other.
The class wide lock and the instance lock being mutually exclusive.
----------------------------------------------
 
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mark stone:
A demon Thread group
1 has only demon threads.
2 can have non demon threads.
3 does not exist after all non demon threads in the group have finished executing.
4 does not exist after all the threads in the group have finished executing.
Answer :4
----------------------------------------------
Assume that th is an instance holding a thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.
True
False
Answer :False
---------------------------------------------
A class has 2 synchronized methods, one being static and other non-static.
which one is correct:

The class wide lock and the instance lock being independent of each other.

The class wide lock and the instance lock being mutually exclusive.
----------------------------------------------


[ January 24, 2002: Message edited by: Rob Ross ]
 
mark stone
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why is the answer false ?

Assume that th is an instance holding a thread object. th.start() causes the thread to start running and eventually complete its execution. The object reference by th is not accessable any more and is garbage collected when the garbage collecter runs.
True
False
Answer :False

Originally posted by Rob Ross:

[ January 24, 2002: Message edited by: Rob Ross ]

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

Originally posted by mark stone:

A class has 2 synchronized methods, one being static and other non-static.
which one is correct:
The class wide lock and the instance lock being independent of each other.
The class wide lock and the instance lock being mutually exclusive.


I remember that above question coming up on JWhiz and was confused how the two answers are really that different? Aren't the two locks independent of each other which also means they are mutually exclusive? (Also, should the word "being" be replaced with "are" ?)
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, if I make a thread...

Thread th = new Thread();
then start the thread...

th.start();
and the thread runs to completion, the thread is dead, but th still contains a reference to the thread. Until you set th to null, this thread object still has a reference to it.
When you write
th = null;
then and only then will the thread above be eligible for garbage collection.

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


A class has 2 synchronized methods, one being static and other non-static.
which one is correct:
The class wide lock and the instance lock being independent of each other.
The class wide lock and the instance lock being mutually exclusive.


Seems very ambiguous I've heard of Object Lock never any "class wide lock" or "instance lock". Is this sort of thing a possiblity on the exam?
reply
    Bookmark Topic Watch Topic
  • New Topic