Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JQ Plus thread question

 
Tejas Tambe
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Q id :958269346510
Which of the following may pause/stop the current thread?
a. calling Thread.yield();
b. calling stop() on an object of class Thread;
c. calling someObject.wait();
d. calling someObject.notify();
e. calling waitForAll() on MediaTracker Object
Correct ans : a,b,c,e
VERY similar question has been asked in SCJP2.
Answer 5 is also correct because how else will MediaTracker do it's job if it does not pause the current thread?

I did not understand the concept behind option e.
Also can u call object.wait().
Please explain.
TIA
Tejas
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since when do the objective for SCJP include knowing about MediaTracker??
I never heard about that requirement before!
Anyway, calling wait() on an object first gives up the lock (the thread has to have the lock on the object before it can call wait()), then it blocks, waiting until it gets notified. It gets notified when some other thread calls notify() on the object the first thread is blocked in.
Rob
 
Shivaji Marathe
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do not believe Media Tracker is included in the SCJP2 objectives or in the exam question.
 
mark stone
Ranch Hand
Posts: 417
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
stop() method is deprecated in 1.2
so (b) should not be in the answer. Please confirm this.

Originally posted by Shivaji Marathe:
I do not believe Media Tracker is included in the SCJP2 objectives or in the exam question.
 
Paul Anilprem
Enthuware Software Support
Ranch Hand
Posts: 3713
10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some people got this type of question in the previous version of the exam. We have not seen anybody getting it in the newer version but who knows
I think, it would be better to clear this fact in the explanation.
HTH,
Paul.
 
Tejas Tambe
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does that mean that the version i got recently from your Indian correspondent , Hanumant deshmukh is old?
I bought this s/w 2 months back...the question bank also contains some questions from jdk1.1 like, bitset. also there are some questions from swing too.
Tejas.
 
Rick Reumann
Ranch Hand
Posts: 281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I did a seach on this question because I just had this question on JQ+. Besides not have a clue about MediaTracker (and now since taking the test on Tuesday, don't even want to mess with it), but how come d) "calling someObj.notify()" is not a correct answer? If there happens to be some other threads waiting couldn't calling notify(), notify one of them and possibly dump the current thread into a paused state while this new thread ones (due to the scheudling of the system)? I must be missunderstanding this question because even the JQ+ study notes mention notify() as a possible way to pause another thread..
http://enthuware.com/jqplus/scjp2notes/Threads.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic