aboutsummaryrefslogtreecommitdiff
path: root/usage_examples/SynchronizedExample_post.jpage
diff options
context:
space:
mode:
Diffstat (limited to 'usage_examples/SynchronizedExample_post.jpage')
-rw-r--r--usage_examples/SynchronizedExample_post.jpage23
1 files changed, 23 insertions, 0 deletions
diff --git a/usage_examples/SynchronizedExample_post.jpage b/usage_examples/SynchronizedExample_post.jpage
new file mode 100644
index 00000000..858bfbde
--- /dev/null
+++ b/usage_examples/SynchronizedExample_post.jpage
@@ -0,0 +1,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");
+ }
+ }
+}