Home | 简体中文 | 繁体中文 | 杂文 | Github | 知乎专栏 | Facebook | Linkedin | Youtube | 打赏(Donations) | About
知乎专栏

第 10 章 Java 并发编程

目录

10.1. TimeUnit
10.2. AtomicInteger / AtomicLong / AtomicBoolean
10.3. AtomicReference
10.4. ReentrantLock 锁
10.5. 线程安全的 HashMap(ConcurrentHashMap)
10.5.1. 设置键与值
10.6. ConcurrentLinkedQueue
10.7. ArrayBlockingQueue
10.8. Future
10.8.1. Future + Stream 管理一组线程
10.9. FutureTask
10.10. CompletableFuture
10.10.1. 创建 CompletableFuture 实例,并且其他线程中使用
10.10.2. runAsync 创建没有返回值的异步任务
10.10.3. thenRun / thenRunAsync
10.10.4. supplyAsync 创建带有返回值的异步任务。
10.10.5. thenAccept / thenAcceptAsync
10.10.6. 获取结果
10.10.7. thenApply / thenApplyAsync
10.10.8. runAsync / thenAccept / thenApply 区别
10.10.9. whenComplete 任务完成时执行,并且返回结果和异常
10.10.10. 超时处理
10.10.11. 按顺序执行
10.10.12. thenCombine、thenAcceptBoth 和runAfterBoth
10.10.13. applyToEither、acceptEither和runAfterEither
10.10.14. allOf / anyOf
10.10.15. 并行执行 CompletableFuture
10.10.16. 通知完成任务
10.10.17. 异常处理
10.10.18. CompletableFuture 实现 Pipeline 流水线
10.11. java 线程池
10.11.1. newCachedThreadPool
10.11.2. 固定线程池(newFixedThreadPool)
10.11.3. Executors.newScheduledThreadPool
10.11.4. SingleThreadExecutor
10.11.5. ExecutorService 正确关闭方法
10.11.6. ForkJoinPool / ForkJoinTask
10.12. Flow
10.12.1. 自定义 Publisher / Subscriber
10.12.2. SubmissionPublisher
10.12.3. Flow.Processor
10.13. Java 协程

包位置 java.util.concurrent

10.1. TimeUnit

		
	try {
		TimeUnit.SECONDS.sleep(5);
	} catch (InterruptedException e) {
	}