auto commit
This commit is contained in:
@ -740,6 +740,7 @@ java.util.concurrent(J.U.C)大大提高了并发性能,AQS 被认为是 J.
|
||||
|
||||
```java
|
||||
public class CountdownLatchExample {
|
||||
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
final int totalThread = 10;
|
||||
CountDownLatch countDownLatch = new CountDownLatch(totalThread);
|
||||
@ -788,6 +789,7 @@ public CyclicBarrier(int parties) {
|
||||
|
||||
```java
|
||||
public class CyclicBarrierExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final int totalThread = 10;
|
||||
CyclicBarrier cyclicBarrier = new CyclicBarrier(totalThread);
|
||||
@ -822,6 +824,7 @@ Semaphore 类似于操作系统中的信号量,可以控制对互斥资源的
|
||||
|
||||
```java
|
||||
public class SemaphoreExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final int clientCount = 3;
|
||||
final int totalRequestCount = 10;
|
||||
@ -866,6 +869,7 @@ FutureTask 可用于异步获取执行结果或取消执行任务的场景。当
|
||||
|
||||
```java
|
||||
public class FutureTaskExample {
|
||||
|
||||
public static void main(String[] args) throws ExecutionException, InterruptedException {
|
||||
FutureTask<Integer> futureTask = new FutureTask<Integer>(new Callable<Integer>() {
|
||||
@Override
|
||||
@ -971,6 +975,7 @@ produce..produce..consume..consume..produce..consume..produce..consume..produce.
|
||||
|
||||
```java
|
||||
public class ForkJoinExample extends RecursiveTask<Integer> {
|
||||
|
||||
private final int threshold = 5;
|
||||
private int first;
|
||||
private int last;
|
||||
|
Reference in New Issue
Block a user