aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/SynchronizedExample_post.jpage
blob: 858bfbdeafa3a86df6ef3bf3ad324923fae004a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
public class SynchronizedExample {
	private static final Object $LOCK = new Object[0];
	private final Object $lock = new Object[0];
	private final Object myLock = new Object();
	
	public static void hello() {
		synchronized($LOCK) {
			System.out.println("world");
		}
	}
	
	public int answerToLife() {
		synchronized($lock) {
			return 42;
		}
	}
	
	public void foo() {
		synchronized(myLock) {
			System.out.println("bar");
		}
	}
}