Java 11 migrate remaining (g,h,i) (#1116)

* Moves game-loop to Java 11

* Moves guarded-suspension to Java 11

* Moves half-sync-half-async to Java 11

* Moves hexagonal to Java 11

* Moves intercepting-filter to Java 11

* Moves interpreter to Java 11

* Moves iterator to Java 11
This commit is contained in:
Anurag Agarwal
2019-12-20 10:41:30 +05:30
committed by Ilkka Seppälä
parent 7d0a5c0edb
commit f835d3d516
68 changed files with 454 additions and 533 deletions

View File

@ -23,7 +23,6 @@
package com.iluwatar.guarded.suspension;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
@ -45,14 +44,11 @@ public class App {
* @param args - command line args
*/
public static void main(String[] args) {
GuardedQueue guardedQueue = new GuardedQueue();
ExecutorService executorService = Executors.newFixedThreadPool(3);
var guardedQueue = new GuardedQueue();
var executorService = Executors.newFixedThreadPool(3);
//here we create first thread which is supposed to get from guardedQueue
executorService.execute(() -> {
guardedQueue.get();
}
);
executorService.execute(guardedQueue::get);
// here we wait two seconds to show that the thread which is trying
// to get from guardedQueue will be waiting
@ -63,10 +59,7 @@ public class App {
}
// now we execute second thread which will put number to guardedQueue
// and notify first thread that it could get
executorService.execute(() -> {
guardedQueue.put(20);
}
);
executorService.execute(() -> guardedQueue.put(20));
executorService.shutdown();
try {
executorService.awaitTermination(30, TimeUnit.SECONDS);

View File

@ -23,13 +23,11 @@
package com.iluwatar.guarded.suspension;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;
/**
* Test for Guarded Queue
@ -39,8 +37,8 @@ public class GuardedQueueTest {
@Test
public void testGet() {
GuardedQueue g = new GuardedQueue();
ExecutorService executorService = Executors.newFixedThreadPool(2);
var g = new GuardedQueue();
var executorService = Executors.newFixedThreadPool(2);
executorService.submit(() -> value = g.get());
executorService.submit(() -> g.put(10));
executorService.shutdown();
@ -54,7 +52,7 @@ public class GuardedQueueTest {
@Test
public void testPut() {
GuardedQueue g = new GuardedQueue();
var g = new GuardedQueue();
g.put(12);
assertEquals(Integer.valueOf(12), g.get());
}