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. ArrayBlockingQueue
10.7. Future
10.7.1. Future + Stream 管理一组线程
10.8. FutureTask
10.9. CompletableFuture
10.9.1. runAsync 创建没有返回值的异步任务
10.9.2. supplyAsync 创建带有返回值的异步任务。
10.9.3. 创建 CompletableFuture 实例,并且其他线程中使用
10.9.4. 获取结果
10.9.5. thenRun / thenRunAsync
10.9.6. thenAccept / thenAcceptAsync
10.9.7. thenApply / thenApplyAsync
10.9.8. runAsync / thenAccept / thenApply 区别
10.9.9. whenComplete 任务完成时执行,并且返回结果和异常
10.9.10. 超时处理
10.9.11. 按顺序执行
10.9.12. thenCombine、thenAcceptBoth 和runAfterBoth
10.9.13. applyToEither、acceptEither和runAfterEither
10.9.14. allOf / anyOf
10.9.15. 并行执行 CompletableFuture
10.9.16. 通知完成任务
10.9.17. 异常处理
10.9.18. CompletableFuture 实现 Pipeline 流水线
10.10. java 线程池
10.10.1. newCachedThreadPool
10.10.2. 固定线程池(newFixedThreadPool)
10.10.3. Executors.newScheduledThreadPool
10.10.4. SingleThreadExecutor
10.10.5. ExecutorService 正确关闭方法
10.10.6. ForkJoinPool / ForkJoinTask
10.11. Flow
10.11.1. 自定义 Publisher / Subscriber
10.11.2. SubmissionPublisher
10.11.3. Flow.Processor
10.12. Java 协程

包位置 java.util.concurrent

10.1. TimeUnit

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