Last active
April 19, 2016 11:41
-
-
Save MarounMaroun/166e6b565123375fa387927c2f4dbf15 to your computer and use it in GitHub Desktop.
Producer code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Producer implements Runnable { | |
| private Data data; | |
| private int id; | |
| public Producer(Data data, int id) { | |
| this.data = data; | |
| this.id = id; | |
| } | |
| @Override | |
| public void run() { | |
| for (int i = 0; i < 100; i++) { | |
| data.put(i); | |
| System.out.println("Producer #" + id + " put: " + i); | |
| try { | |
| Thread.sleep(200); | |
| } catch (InterruptedException e) { } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment