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/3ba0f01982e946c0f88295670df5ff3f to your computer and use it in GitHub Desktop.

Select an option

Save MarounMaroun/3ba0f01982e946c0f88295670df5ff3f to your computer and use it in GitHub Desktop.
public class Consumer implements Runnable {
private Data data;
private int id;
public Consumer(Data data, int id) {
this.data = data;
this.id = id;
}
@Override
public void run() {
for (int i = 0; i < 100; i++) {
try {
Thread.sleep(200);
} catch (InterruptedException e) { }
System.out.println("Consumer #" + id + " get: " + data.get());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment