Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void doSomething() {
- // thread-safe code
- synchronized(this) {
- // thread-unsafe code
- }
- // thread-safe code
- }
- public void foo() {
- synchronized (this) {
- // do something thread-safe
- }
- }
- public synchronized void foo() {
- // do something thread-safe
- }
- Vector v = getSomeGlobalVector();
- synchronized (v) {
- // some thread-safe operation on the vector
- }
- public class Foo {
- private final Object syncObject = new Object();
- …
- }
- private Object mutex=new Object();
Add Comment
Please, Sign In to add comment