wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes threads Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "threads" Watch "threads" New topic
Author

threads

preeti khane
Ranch Hand

Joined: Mar 12, 2003
Posts: 93

Can someone give me the correct answers and explanation
thank you
Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
i guess the answers are 1, 2 and 3.
The methods a(), b() and c() are synchronized. So any thread that is accessing one of the methods cannot access rest two untill it finishes with the first method in a given object of class Q7ed5. Every method takes care of incrementing as well as decrementing the variables too, hence the value of variable 'v' switches between 0 and 1.
If am wrong correct me.
[ April 03, 2003: Message edited by: Reshma Pai ]
[ April 03, 2003: Message edited by: Reshma Pai ]

SCJP 1.4, SCWCD 1.4
preeti khane
Ranch Hand

Joined: Mar 12, 2003
Posts: 93
Answer in the exam is only 1 and 2
Reshma Shanbhag
Ranch Hand

Joined: Sep 17, 2002
Posts: 202
Hey i mistaked thinking that method c() is synchronized.. since it is not, thevalue of k.v cannot be predcited...
the Answer's 1 & 2 are right.. sorry for the mistake .
reshma
[ April 03, 2003: Message edited by: Reshma Pai ]
 
GeeCON Prague 2014
 
subject: threads