Compare commits
2 Commits
fbf515f1bb
...
ab8c68d90f
Author | SHA1 | Date | |
---|---|---|---|
ab8c68d90f | |||
10267d6f8b |
@ -47,6 +47,10 @@ public class Main {
|
||||
|
||||
// 关闭线程池
|
||||
forkJoinPool.shutdown();
|
||||
|
||||
System.out.println(IntStream.range(0, 1000).parallel().reduce((i, j) -> i + j));
|
||||
System.out.println(IntStream.range(0, 1000).parallel().reduce(Integer::sum));
|
||||
System.out.println(IntStream.range(0, 1000).parallel().sum());
|
||||
}
|
||||
|
||||
static class RecursiveTaskDemo extends RecursiveTask<Integer> {
|
||||
@ -54,6 +58,7 @@ public class Main {
|
||||
* 每个"小任务"最多只打印70个数
|
||||
*/
|
||||
private static final int MAX = 100;
|
||||
private static final long serialVersionUID = -134954066152987391L;
|
||||
private final int[] arr;
|
||||
private final int start;
|
||||
private final int end;
|
||||
|
@ -158,7 +158,7 @@ public class SnowflakeIdUtil {
|
||||
// 上次生成 id 的时间截
|
||||
lastTimestamp = timestamp;
|
||||
|
||||
// 移位并通过或运算拼到一起组成 64 位的 id
|
||||
// 移位并通过或运算拼到一起组成 64 位的 id
|
||||
return ((timestamp - twepoch) << timestampLeftShift)
|
||||
| (datacenterId << datacenterIdShift)
|
||||
| (workerId << workerIdShift)
|
||||
|
Loading…
Reference in New Issue
Block a user