|
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;
}
}
|