samples/reentrant/src/org/apidesign/reentrant/CriticalSectionSynchronizedWithNonReentrantLock.java
1 package org.apidesign.reentrant;
3 import java.nio.channels.NonReadableChannelException;
4 import java.util.Collection;
5 import java.util.concurrent.locks.Lock;
7 public class CriticalSectionSynchronizedWithNonReentrantLock<T extends Comparable<T>> implements CriticalSection<T> {
11 public void assignPilot(T pilot) {
20 // BEGIN: reentrant.nonreentrant.lock
21 private Lock lock = new NonReentrantLock();
22 public int sumBigger(Collection<T> args) {
25 return doCriticalSection(args);
30 // END: reentrant.nonreentrant.lock
32 private int doCriticalSection(Collection<T> args) {
34 if (pilot.compareTo(cmp) < 0) {
41 public int getCount() {