Biblioteca Java - Blame information for rev 28
Subversion Repositories:
Rev | Author | Line No. | Line |
---|---|---|---|
28 | mihai | 1 | /* |
2 | * Producer.java | ||
3 | */ | ||
4 | package exemple.fire.sincronizareProducerConsumer; | ||
5 | |||
6 | /** | ||
7 | * Class created by @author Mihai HULEA at Feb 22, 2005. | ||
8 | * | ||
9 | * This class is part of the labs project. | ||
10 | * | ||
11 | */ | ||
12 | class Producer implements Runnable | ||
13 | { | ||
14 | private Buffer bf; | ||
15 | private Thread thread; | ||
16 | Producer(Buffer bf) | ||
17 | {this.bf=bf; | ||
18 | } | ||
19 | |||
20 | public void start() | ||
21 | { | ||
22 | if (thread==null) | ||
23 | { | ||
24 | thread = new Thread(this); | ||
25 | thread.start(); | ||
26 | } | ||
27 | } | ||
28 | public void run() | ||
29 | { | ||
30 | while (true) | ||
31 | { | ||
32 | System.out.println("Am scris."); | ||
33 | bf.put(Math.random()); | ||
34 | try | ||
35 | {Thread.sleep(1000); | ||
36 | }catch(Exception e){} | ||
37 | } | ||
38 | } | ||
39 | } | ||
40 |