File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed
src/main/java/com/java15/example/concurrency1 Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .java15 .example .concurrency1 ;
2
+
3
+ import java .util .concurrent .ExecutionException ;
4
+ import java .util .concurrent .FutureTask ;
5
+ import java .util .function .UnaryOperator ;
6
+ import java .util .stream .Stream ;
7
+
8
+ public class Application {
9
+ public static void main (String [] args ) throws ExecutionException , InterruptedException {
10
+ /* FutureTask<String> futureTask = new FutureTask<>(new CallableImpl());
11
+ Thread thread = new Thread(futureTask);
12
+ thread.start();
13
+ Thread.sleep(100);
14
+ System.out.println(futureTask.get());*/
15
+ streamDemo ();
16
+ }
17
+
18
+
19
+ static public void streamDemo (){
20
+ UnaryOperator <String > lowerCase = String ::toLowerCase ;
21
+ //Stream.generate(()->"Hello World!").forEach(System.out::println);
22
+ Stream .iterate ("Hello World!" ,lowerCase ).forEach (System .out ::println );
23
+
24
+ }
25
+ }
Original file line number Diff line number Diff line change
1
+ package com .java15 .example .concurrency1 ;
2
+
3
+ import java .util .concurrent .Callable ;
4
+
5
+ public class CallableImpl implements Callable <String > {
6
+ @ Override
7
+ public String call () throws Exception {
8
+ return "Hello World" ;
9
+ }
10
+ }
You can’t perform that action at this time.
0 commit comments