samples/reentrant/src/org/apidesign/reentrant/CriticalSectionSynchronizedWithAssert.java
1 package org.apidesign.reentrant;
3 import java.util.Collection;
5 public class CriticalSectionSynchronizedWithAssert<T extends Comparable<T>> implements CriticalSection<T> {
9 public synchronized void assignPilot(T pilot) {
10 assert !working : "Shall not be working yet in order to be consistent";
14 // BEGIN: reentrant.assert
15 private boolean working;
16 public int sumBigger(Collection<T> args) {
17 assert !working : "Shall not be working yet in order to be consistent";
20 return doCriticalSection(args);
25 // END: reentrant.assert
28 private int doCriticalSection(Collection<T> args) {
30 if (pilot.compareTo(cmp) < 0) {
37 public int getCount() {
38 assert !working : "Shall not be working yet in order to be consistent";