Specifications

Sun Services
Java™ Programming Language
Module 13, slide 22 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Using synchronized Putting It Together
The following two code segments are equivalent:
public void push(char c) {
synchronized(this) {
// The push method code
}
}
public synchronized void push(char c) {
// The push method code
}