1c13e54baffc0acb926b717c5d66f5bec8fddc37
4 * implementation du producteur consommateur avec un buffer circulaire
6 public class BufferCirc
{
8 private Object
[] tampon
;
10 private int prem
, der
, nbObj
;
13 public BufferCirc (int t
) {
15 tampon
= new Object
[taille
];
22 public boolean isEmpty() {
27 public boolean isFull() {
28 return nbObj
== taille
;
32 public synchronized void depose(Object obj
) {
37 catch (InterruptedException e
) {}
41 prem
= (prem
+ 1) % taille
;
42 //System.out.println(Thread.currentThread().getName() + " a depose " + (Integer)obj);
47 public synchronized Object
preleve() {
52 catch (InterruptedException e
) {}
57 der
= (der
+ 1) % taille
;
58 //System.out.println(Thread.currentThread().getName() + " a preleve " + (Integer)outObj);
63 } // fin class BufferCirc