Skip to content

Commit 5080e60

Browse files
committed
add homework 0303
1 parent e2097ab commit 5080e60

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package java0.conc0303;
2+
3+
public class Homework03 {
4+
5+
public static void main(String[] args) {
6+
7+
// 在这里创建一个线程或线程池,
8+
// 异步执行 下面方法
9+
10+
11+
long start=System.currentTimeMillis();
12+
13+
int result = sum(); //这是得到的返回值
14+
// 确保 拿到result 并输出
15+
System.out.println("异步计算结果为:"+result);
16+
17+
18+
System.out.println("使用时间:"+ (System.currentTimeMillis()-start) + " ms");
19+
20+
// 然后退出main线程
21+
}
22+
23+
private static int sum() {
24+
return fibo(36);
25+
}
26+
27+
private static int fibo(int a) {
28+
if ( a < 2)
29+
return 1;
30+
return fibo(a-1) + fibo(a-2);
31+
}
32+
}

0 commit comments

Comments
 (0)