From 8b7a7cbc813653a3248d6cf3a7779e220957bc85 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 8 May 2017 21:28:02 +0200 Subject: The great rename: the old ‘website’ is now ‘website-old’, and ‘website2’ is now ‘website’. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../usageExamples/SynchronizedExample_post.jpage | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 website/usageExamples/SynchronizedExample_post.jpage (limited to 'website/usageExamples/SynchronizedExample_post.jpage') diff --git a/website/usageExamples/SynchronizedExample_post.jpage b/website/usageExamples/SynchronizedExample_post.jpage new file mode 100644 index 00000000..219ab88a --- /dev/null +++ b/website/usageExamples/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 readLock = new Object(); + + public static void hello() { + synchronized($LOCK) { + System.out.println("world"); + } + } + + public int answerToLife() { + synchronized($lock) { + return 42; + } + } + + public void foo() { + synchronized(readLock) { + System.out.println("bar"); + } + } +} -- cgit