Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main {
- public static void main(String[] args) throws InterruptedException{
- Fabrika fabrika = new Fabrika(2);
- Thread t1 = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- fabrika.produce("v1");
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
- Thread t3 = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- fabrika.produce("v2");
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
- Thread t2 = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- fabrika.consume();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
- Thread t4 = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- fabrika.consume();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- });
- t1.start();
- t2.start();
- t3.start();
- t4.start();
- t1.join();
- t3.join();
- t2.join();
- t4.join();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement