Skip to content

Instantly share code, notes, and snippets.

@MarounMaroun
Last active April 19, 2016 11:41
Show Gist options
  • Select an option

  • Save MarounMaroun/166e6b565123375fa387927c2f4dbf15 to your computer and use it in GitHub Desktop.

Select an option

Save MarounMaroun/166e6b565123375fa387927c2f4dbf15 to your computer and use it in GitHub Desktop.
Producer code
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