View Single Post
  #3 (permalink)  
Old 10-07-2008, 08:07 PM
mrhyman mrhyman is offline
Member
 
Join Date: Oct 2008
Posts: 8
mrhyman is on a distinguished road
Thanks but actually I was more looking for a confirmation or example how to do this in my sitation. I had already read the Concurrency part on the Sun Page but as I said, I am new to java.

Here's how I am thinking of doing it:

private float Balance = float (1.0);
private Object Lock1 = new Object();

Public buyitem(){

synchronized(Lock1){
Balance = Balance / 2;
sellitem();
}


public sellitem(){

synchronized(Lock1){
Balance = Balance * 2;
}
}
Reply With Quote