11package com .baeldung .concurrent .runnable ;
22
33import java .util .concurrent .Callable ;
4- import java .util .concurrent .ExecutionException ;
54import java .util .concurrent .ExecutorService ;
65import java .util .concurrent .Executors ;
76import java .util .concurrent .Future ;
87
98import org .apache .commons .lang3 .RandomUtils ;
10- import org .junit .After ;
119import org .junit .AfterClass ;
12- import org .junit .Before ;
1310import org .junit .BeforeClass ;
1411import org .junit .Test ;
1512import org .slf4j .Logger ;
1613import org .slf4j .LoggerFactory ;
1714
18- public class RunnableVsThreadTest {
15+ public class RunnableVsThreadLiveTest {
1916
2017 private static Logger log =
21- LoggerFactory .getLogger (RunnableVsThreadTest .class );
18+ LoggerFactory .getLogger (RunnableVsThreadLiveTest .class );
2219
2320 private static ExecutorService executorService ;
2421
@@ -77,9 +74,7 @@ public void givenACallable_whenSubmitToES_thenResult() throws Exception {
7774 public void givenACallableAsLambda_whenSubmitToES_thenResult ()
7875 throws Exception {
7976
80- Future <Integer > future = executorService .submit (() -> {
81- return RandomUtils .nextInt (0 , 100 );
82- });
77+ Future <Integer > future = executorService .submit (() -> RandomUtils .nextInt (0 , 100 ));
8378
8479 log .info ("Result from callable: {}" , future .get ());
8580 }
@@ -99,7 +94,7 @@ class SimpleThread extends Thread{
9994
10095 private String message ;
10196
102- public SimpleThread (String message ) {
97+ SimpleThread (String message ) {
10398 this .message = message ;
10499 }
105100
@@ -116,7 +111,7 @@ class SimpleRunnable implements Runnable {
116111
117112 private String message ;
118113
119- public SimpleRunnable (String message ) {
114+ SimpleRunnable (String message ) {
120115 this .message = message ;
121116 }
122117
0 commit comments