课程: Java: Advanced Concepts for High-Performance Development

今天就学习课程吧!

今天就开通帐号,24,700 门业界名师课程任您挑!

Solution: Name

Solution: Name

- So let's have a look at the solution to this exercise. So inside the Store methods I'm going to be writing my code inside the main method. The first part of the exercise is to create a new StockChecker object. So I'm going to add a new line and I'm going to say StockChecker. stockChecker equals new StockChecker. So that's the first part done. The second part says to create an ExecutorService with a fixed thread pool of four threads. So on another new line, I'm going to say ExecutorService. executorService equals and then I'm going to say executors. And then I'm going to call the static method newFixedThreadPool and pass in four. The next part says to submit four tasks to the executor service. And in each task, I should call the purchase method and pass in 20 to represent a customer purchasing 20 items. So I'm going to say executorService.submit and then I'm going to pass in a Lambda for my runnable. So I'm going to…

内容