author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:54:36 +0200 | |
changeset 111 | 3905a2e66b9b |
permissions | -rw-r--r-- |
1 package org.apidesign.reentrant;
3 import java.util.Collection;
5 public class CriticalSectionSynchronized<T extends Comparable<T>> implements CriticalSection<T> {
6 private T pilot;
7 private int cnt;
9 public synchronized void assignPilot(T pilot) {
10 this.pilot = pilot;
11 }
13 public int sumBigger(Collection<T> args) {
14 for (T cmp : args) {
15 if (pilot.compareTo(cmp) < 0) {
16 cnt++;
17 }
18 }
19 return cnt;
20 }
22 public int getCount() {
23 return cnt;
24 }
25 }