author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Fri, 03 Apr 2020 16:32:36 +0200 | |
changeset 416 | 9ed8788a1a4e |
permissions | -rw-r--r-- |
jtulach@144 | 1 |
package org.apidesign.samples; |
jtulach@144 | 2 |
|
jtulach@144 | 3 |
public class Synchronization { |
jtulach@144 | 4 |
private final Object anObject = new Object(); |
jtulach@144 | 5 |
|
jtulach@144 | 6 |
public void methodUsingSynchronizedBlock() { |
jtulach@144 | 7 |
// BEGIN: synchronize.anObject |
jtulach@144 | 8 |
synchronized (anObject) { |
jtulach@144 | 9 |
// do the critical stuff |
jtulach@144 | 10 |
} |
jtulach@144 | 11 |
// END: synchronize.anObject |
jtulach@144 | 12 |
} |
jtulach@144 | 13 |
} |