Java Reference
In-Depth Information
8.4.3.5. strictfp Methods
The effect of the strictfp modifier is to make all float or double expressions within the method
body be explicitly FP-strict (§ 15.4 ) .
8.4.3.6. synchronized Methods
A synchronized method acquires a monitor (§ 17.1 ) before it executes.
For a class ( static ) method, the monitor associated with the Class object for the method's class
is used.
For an instance method, the monitor associated with this (the object for which the method
was invoked) is used.
Example 8.4.3.6-1. synchronized Monitors
These are the same monitors that can be used by the synchronized statement (§ 14.19 ).
Thus, the code:
Click here to view code image
class Test {
int count;
synchronized void bump() {
count++;
}
static int classCount;
static synchronized void classBump() {
classCount++;
}
}
has exactly the same effect as:
Click here to view code image
class BumpTest {
int count;
void bump() {
synchronized (this) { count++; }
}
static int classCount;
static void classBump() {
try {
synchronized (Class.forName("BumpTest")) {
classCount++;
Search WWH ::




Custom Search