01: package demo.bank.transaction.implicit;
02:
03: public class Lock {
04: private boolean locked;
05:
06: public Lock() {
07: locked = false;
08: }
09:
10: public synchronized void lock() {
11: while (locked) {
12: try {
13: wait();
14: } catch (InterruptedException ie) {
15: }
16: }
17: locked = true;
18: }
19:
20: public synchronized void unlock() {
21: locked = false;
22: notifyAll();
23: }
24: }
|