Java 11 migration: patterns (t-v) (#1085)
* Moves visitor pattern to java 11 * Moves value-object pattern to java 11 * Moves unit-of-work pattern to java 11 * Moves typeobjectpattern pattern to java 11 * Moves twin pattern to java 11 * Moves trampoline pattern to java 11 * Moves tolerant-reader pattern to java 11 * Moves tls pattern to java 11 * Moves throttling pattern to java 11 * Moves thread-pool pattern to java 11 * Moves template-method pattern to java 11
This commit is contained in:
committed by
Ilkka Seppälä
parent
160b737dcc
commit
50467c9e76
@ -56,7 +56,7 @@ public class App {
|
||||
LOGGER.info("Program started");
|
||||
|
||||
// Create a list of tasks to be executed
|
||||
List<Task> tasks = List.of(
|
||||
var tasks = List.of(
|
||||
new PotatoPeelingTask(3),
|
||||
new PotatoPeelingTask(6),
|
||||
new CoffeeMakingTask(2),
|
||||
@ -82,10 +82,7 @@ public class App {
|
||||
// Allocate new worker for each task
|
||||
// The worker is executed when a thread becomes
|
||||
// available in the thread pool
|
||||
for (int i = 0; i < tasks.size(); i++) {
|
||||
var worker = new Worker(tasks.get(i));
|
||||
executor.execute(worker);
|
||||
}
|
||||
tasks.stream().map(Worker::new).forEach(executor::execute);
|
||||
// All tasks were executed, now shutdown
|
||||
executor.shutdown();
|
||||
while (!executor.isTerminated()) {
|
||||
|
Reference in New Issue
Block a user