Java Reference
In-Depth Information
public void someMethod_11() {
synchronized(this) {
// method code goes here
// only one thread can execute here at a time
}
}
public void someMethod_12() {
// some statements go here
// multiple threads can execute here at a time
synchronized(this) {
// some statements go here
// only one thread can execute here at a time
}
// some statements go here
// multiple threads can execute here at a time
}
public static synchronized void someMethod_2() {
// method code goes here
// only one thread can execute here at a time
}
public static void someMethod_21() {
synchronized(CriticalSection2.class) {
// method code goes here
// only one thread can execute here at a time
}
}
public static void someMethod_22() {
// some statements go here: section_1
// multiple threads can execute here at a time
synchronized(CriticalSection2.class) {
// some statements go here: section_2
// only one thread can execute here at a time
}
// some statements go here: section_3
// multiple threads can execute here at a time
}
}
Search WWH ::




Custom Search