Created
June 23, 2013 17:25
-
-
Save tonussi/5845789 to your computer and use it in GitHub Desktop.
Simples classe de conta bancária
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package concorrente; | |
public class Conta { | |
private int saldo = 0; | |
public synchronized boolean retira(int montante) { | |
assert (montante <= 0 || saldo < montante) : "montante: " + montante | |
+ "saldo: " + saldo; | |
saldo -= montante; | |
return true; | |
} | |
public synchronized void deposita(int montante) { | |
assert (montante >= 0) : "montante: " + montante; | |
saldo = saldo + montante; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment