Biblioteca Java - Blame information for rev 28
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
28 | mihai | 1 | /* |
2 | * Buffer.java | ||
3 | */ | ||
4 | package exemple.fire.sincronizareProducerConsumer; | ||
5 | |||
6 | import java.util.ArrayList; | ||
7 | |||
8 | /** | ||
9 | * Class created by @author Mihai HULEA at Feb 22, 2005. | ||
10 | * | ||
11 | * This class is part of the labs project. | ||
12 | * | ||
13 | */ | ||
14 | class Buffer | ||
15 | { | ||
16 | ArrayList content = new ArrayList(); | ||
17 | synchronized void put(double d) | ||
18 | { | ||
19 | content.add(new Double(d)); | ||
20 | notify(); | ||
21 | } | ||
22 | |||
23 | synchronized double get() | ||
24 | { | ||
25 | double d=-1; | ||
26 | try | ||
27 | { | ||
28 | if(content.size()==0) wait(); | ||
29 | d = (((Double)content.get(0))).doubleValue(); | ||
30 | content.remove(0); | ||
31 | }catch(Exception e){e.printStackTrace();} | ||
32 | |||
33 | return d; | ||
34 | } | ||
35 | } |