Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package prj7_blockingdeque;
- import java.util.concurrent.BlockingDeque;
- public class ProducentDeque implements Runnable {
- private String jmeno;
- private BlockingDeque<Integer> deque;
- public ProducentDeque(String jmeno, BlockingDeque<Integer> deque) {
- this.jmeno = jmeno;
- this.deque = deque;
- }
- public void run() {
- for (int i = 1; i <= 5; i++) {
- try {
- deque.putLast(i);
- // ... bloková metoda (pro LIFO - zůstává putLast())
- System.out.println(jmeno + " ukládá " + i);
- Thread.sleep(0);
- //... kombinujte časy (0 ... 5000)
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment