/** Perform a synchronized on a local object within a loop. */
@Benchmark publicvoid testSimpleLockUnlock() {
Object localObject = lockObject1; for (int i = 0; i < innerCount; i++) { synchronized (localObject) {
dummyInt1++;
dummyInt2++;
}
}
}
/** Perform a recursive synchronized on a local object within a loop. */
@Benchmark publicvoid testRecursiveLockUnlock() {
Object localObject = lockObject1; for (int i = 0; i < innerCount; i++) { synchronized (localObject) { synchronized (localObject) {
dummyInt1++;
dummyInt2++;
}
}
}
}
/** Perform two synchronized after each other on the same local object. */
@Benchmark publicvoid testSerialLockUnlock() {
Object localObject = lockObject1; for (int i = 0; i < innerCount; i++) { synchronized (localObject) {
dummyInt1++;
} synchronized (localObject) {
dummyInt2++;
}
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.