Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Override
- public StatisticResult call() {
- ExecutorService executor = Executors.newFixedThreadPool(4);
- Drop drop = new Drop();
- Random random = new Random();
- StatisticWorker statictic = new StatisticWorker(drop);
- Producer producer = new Producer(drop);
- executor.submit(producer);
- Future<StatisticResult> result = executor.submit(statictic);
- PrintWorker printWorker = new PrintWorker(statictic.getStatistic());
- executor.submit(printWorker);
- for (int i = 0; i < 500; i++) {
- executor.submit(new Consumer(drop));
- sleep(random);
- }
- printWorker.stop();
- producer.stop();
- statictic.stop();
- executor.shutdown();
- return getResult(result);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement