Meaningless Drivel is fun!
The moose likes Threads and Synchronization and the fly likes synchronization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "synchronization" Watch "synchronization" New topic


Eric Lidell

Joined: Jul 02, 2003
Posts: 20
Look at the following question i picked up in the internet.
public class Vertical {
private int alt;
public synchronized void up() {
public void down() {
public synchronized void jump() {
int a = alt;
assert(a == alt);
if the code is run with assertions enabled ,what are the possible answers?
a.The code will fail to compile.
b.Seperate threads can execute up() concurrently
c.Seperate threads can execute down() concurrently
d.Seperate threads can execute both up() & down() concurrently
e.the assertion wont fail under any circumstance.
What is the possible answer and the reason?
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
Simon Templar,
We don't have many rules at JavaRanch, but one that we do have is a naming convention. If you would be a saint and kindly change your display name to conform, it would be most appreciated.
Jason (moderator)
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
I'm moving this to The Threads and Synchronization Forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
I agree. Here's the link:
subject: synchronization
jQuery in Action, 3rd edition