首页 > 技术文章 > 0928-----homework

kaililikai 2016-09-28 22:14 原文

 1 /**
 2   *homework0928
 3   *@author:kai li
 4   */
 5 package com.kai.li.homework0928;
 6 import java.util.stream.IntStream;
 7 /**
 8   *following class is client 
 9   */
10 public class HomeWork0928{
11 
12     public static void main(String[] args)throws Exception{
13         
14         /**
15           *question one and two
16           */
17     
18     Runnable runnable1=()->{
19                 long timeStart=System.currentTimeMillis();
20                 IntStream.range(1,101)
21                 .mapToObj(i->"洛阳"+i)
22                 .forEach(System.out::println);
23                 long time1=System.currentTimeMillis()-timeStart;
24                 System.out.println(time1);
25             };
26     Runnable runnable2=()->{
27                 long timeStart=System.currentTimeMillis();
28                 IntStream.range(1,101)
29                 .mapToObj(i->"长安"+i)
30                 .forEach(System.out::println);
31                 long time2=System.currentTimeMillis()-timeStart;
32                 System.out.println(time2);
33             };
34     Runnable runnable3=()->{
35                 IntStream.range(1,101)
36                 .mapToObj(i->"runnable3:燕京"+i)
37                 .forEach(System.out::println);
38             };
39     Thread thread1=new Thread(runnable1);
40     Thread thread2=new Thread(runnable2);
41     Thread thread3=new Thread(runnable3);
42     thread1.start();
43     thread2.start();
44     thread3.start();
45 
46     IntStream.range(1,101)
47                 .mapToObj(i->"main:开封府"+i)
48                 .forEach(System.out::println);
49     
50     }
51 }

 

推荐阅读