This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: threads
 
Similar Threads
Synchronization Methods
Mughal rasmussen question
Thread Question
Dumb question about threads
synchronized methods + Threads