kindle电子书

资源下载,尽在我的书库!
首页 > kindle电子书库 > 工业|计算机|互联网 > 电子、计算机、网络

Java并发编程:核心方法与框架 (Java核心技术系列)

  • 作者:[中] 高洪岩
  • 体积:20.85 MB
  • 语言:中文
  • 日期:2018-07-28
  • 推荐:

简介:Java并发编程:核心方法与框架 (Java核心技术系列)

电子书详细介绍

 本书尽量减少“啰嗦”式的文字语言,全部用Demo式案例来讲解技术点的实现,使读者看到代码及运行结果后就可以知道此项目要解决的是什么问题。类似于网络中Blog的风格,可让读者用最短的时间学会此知识点,明白此知识点如何应用,以及在使用时要避免什么。这就像“瑞士军刀”,虽短小,却锋利。本书的目的就是帮读者快速学习并解决问题。

编辑推荐

《Java并发编程:核心方法与框架》由机械工业出版社出版。

作者简介

高洪岩,某世界500强企业高级项目经理,10余年项目管理与开发经验,10年Java相关开发经验,深谙Java技术开发难点与要点,拥有良好的技术素养和丰富的实践经验。精通J2EE核心技术、基于EJB的分布式系统开发、Android移动开发、智能报表、多线程及高并发等相关的技术内容,近期继续关注并发相关的前沿技术。著有技术畅销书《Java多线程编程核心技术》,喜欢将技术与教育相结合的方式共享知识,得以共同提高。生活中喜欢摄影,对轮滑,旅游,航模亦兴趣浓厚。

 

目录

前言 
第1章 Semaphore和Exchanger的使用 1 
1.1 Semaphore的使用 2 
1.1.1 类Semaphore的同步性 2 
1.1.2 类Semaphore构造方法permits参数作用 4 
1.1.3 方法acquire(int permits)参数作用及动态添加permits许可数量 5 
1.1.4 方法acquire Uninterruptibly()的使用 8 
1.1.5 方法available Permits()和drain Permits() 10 
1.1.6 方法get Queue Length()和has Queued Threads() 12 
1.1.7 公平与非公平信号量的测试 13 
1.1.8 方法try Acquire()的使用 15 
1.1.9 方法try Acquire(int permits)的使用 17 
1.1.10 方法try Acquire(long timeout, Time Unit unit)的使用 17 
1.1.11 方法try Acquire(int permits, long timeout, Time Unit unit)的使用 19 
1.1.12 多进路—多处理—多出路实验 20 
1.1.13 多进路—单处理—多出路实验 21 
1.1.14 使用Semaphore创建字符串池 23 
1.1.15 使用Semaphore实现多生产者/多消费者模式 25 
1.2 Exchanger的使用 31 
1.2.1 方法exchange()阻塞的特性 31 
1.2.2 方法exchange()传递数据 32 
1.2.3 方法exchange(V x, long timeout, Time Unit unit)与超时 34 
1.3 本章总结 35 
第2章 Count Down Latch和Cyclic Barrier的使用 36 
2.1 Count Down Latch的使用 36 
2.1.1 初步使用 37 
2.1.2 裁判在等全部的运动员到来 38 
2.1.3 各就各位准备比赛 39 
2.1.4 完整的比赛流程 41 
2.1.5 方法await(long timeout, Time Unit unit) 44 
2.1.6 方法get Count()的使用 46 
2.2 Cyclic Barrier的使用 46 
2.2.1 初步使用 48 
2.2.2 验证屏障重置性及getNumberWaiting()方法的使用 51 
2.2.3 用Cyclic Barrier类实现阶段跑步比赛 52 
2.2.4 方法is Broken()的使用 55 
2.2.5 方法await(long timeout, Time Unit unit)超时出现异常的测试 57 
2.2.6 方法get Number Waiting()和get Parties() 60 
2.2.7 方法reset() 62 
2.3 本章总结 64 
第3章 Phaser的使用 65 
3.1 Phaser的使用 66 
3.2 类Phaser的arrive And Await Advance()方法测试166 
3.3 类Phaser的arrive And Await Advance()方法测试268 
3.4 类Phaser的arrive And Deregister()方法测试 69 
3.5 类Phaser的get Phase()和on Advance()方法测试 70 
3.6 类Phaser的get Registered Parties()方法和register()测试 74 
3.7 类Phaser的bulk Register()方法测试 75 
3.8 类Phaser的get Arrived Parties()和get Unarrived Parties()方法测试 75 
3.9 类Phaser的arrive()方法测试177 
3.10 类Phaser的arrive ()方法测试278 
3.11 类Phaser的await Advance(int phase)方法测试 81 
3.12 类Phaser的await Advance Interruptibly(int)方法测试183 
3.13 类Phaser的await Advance Interruptibly(int)方法测试284 
3.14 类Phaser的await Advance Interruptibly(int)方法测试386 
3.15 类Phaser的await Advance Interruptibly(int,long,Time Unit)方法测试487 
3.16 类Phaser的force Termination()和is Terminated()方法测试 89 
3.17 控制Phaser类的运行时机 92 
3.18 本章总结 93 
第4章 Executor与Thread Pool Executor的使用 94 
4.1 Executor接口介绍 94 
4.2 使用Executors工厂类创建线程池 97 
4.2.1 使用new Cached Thread Pool()方法创建无界线程池 98 
4.2.2 验证new Cached Thread Pool()创建为Thread池 100 
4.2.3 使用new Cached Thread Pool (Thread Factory)定制线程工厂 102 
4.2.4 使用new Fixed Thread Pool(int)方法创建有界线程池 103 
4.2.5 使用new Fixed Thread Pool(int, Thread Factory)定制线程工厂 105 
4.2.6 使用new Single Thread Executor()方法创建单一线程池 106 
4.2.7 使用new Single Thread Executor(Thread Factory)定制线程工厂 107 
4.3 Thread Pool Executor的使用 107 
4.3.1 构造方法的测试 107 
4.3.2 方法shutdown()和shutdown Now()与返回值 119 
4.3.3 方法is Shutdown() 129 
4.3.4 方法is Terminating ()和is Terminated () 129 
4.3.5 方法await Termination(long timeout,Time Unit unit) 131 
4.3.6 工厂Thread Factory+execute()+UncaughtException Handler处理异常 134 
4.3.7 方法set/get Rejected Execution Handler() 138 
4.3.8 方法allows Core Thread Time Out()/(boolean) 140 
4.3.9 方法prestart Core Thread()和prestart All Core Threads() 142 
4.3.10 方法get Completed Task Count() 144 
4.3.11 常见3种队列结合max值的因果效果 145 
4.3.12 线程池Thread Pool Executor的拒绝策略 151 
4.3.13 方法after Execute()和before Execute() 157 
4.3.14 方法remove(Runnable)的使用 159 
4.3.15 多个get方法的测试 162 
4.3.16 线程池Thread Pool Executor与Runnable执行为乱序特性 166 
4.4 本章总结 167 
第5章 Future和Callable的使用 168 
5.1 Future和Callable的介绍 168 
5.2 方法get()结合Executor Service中的submit(Callable)的使用 168 
5.3 方法get()结合Executor Service中的submit(Runnable)和is Done()的使用 170 
5.4 使用Executor Service接口中的方法submit(Runnable, T result) 170 
5.5 方法cancel(boolean may Interrupt If Running)和is Cancelled()的使用 173 
5.6 方法get(long timeout, Time Unit unit)的使用 178 
5.7 异常的处理 179 
5.8 自定义拒绝策略Rejected Execution Handler接口的使用 181 
5.9 方法execute()与submit()的区别 182 
5.10 验证Future的缺点 186 
5.11 本章总结 188 
第6章 Completion Service的使用 189 
6.1 Completion Service介绍 189 
6.2 使用Completion Service解决Future的缺点 190 
6.3 使用take()方法 193 
6.4 使用poll()方法 194 
6.5 使用poll(long timeout, Time Unit unit)方法 195 
6.6 类Completion Service与异常 199 
6.7 方法Future submit(Runnable task, V result)的测试 205 
6.8 本章总结 207 
第7章 接口Executor Service的方法使用 208 
7.1 在Thread Pool Executor中使用Executor Service中的方法 208 
7.2 方法invoke Any(Collection tasks)的使用与interrupt 209 
7.3 方法invoke Any()与执行慢的任务异常 212 
7.4 方法invoke Any()与执行快的任务异常 216 
7.5 方法invoke Any()与全部异常 220 
7.6 方法invoke Any(Collection Tasks, timeout, time Unit)超时的测试 222 
7.7 方法invoke All(Collection tasks)全正确 226 
7.8 方法invoke All(Collection tasks)快的正确慢的异常 227 
7.9 方法invoke All(Collection tasks)快的异常慢的正确 230 
7.10 方法invoke All(Collection tasks,long timeout,Time Unit unit)先慢后快 232 
7.11 方法invoke All(Collection tasks,long timeout,Time Unit unit)先快后慢 234 
7.12 方法invoke All(Collection tasks,long timeout,Time Unit unit)全慢 236 
7.13 本章总结 238 
第8章 计划任务Scheduled Executor Service的使用 239 
8.1 Scheduled Executor Service的使用 240 
8.2 Scheduled Thread Pool Executor使用Callable延迟运行 241 
8.3 Scheduled Thread Pool Executor使用Runnable延迟运行 244 
8.4 延迟运行并取得返回值 245 
8.5 使用schedule At Fixed Rate()方法实现周期性执行 246 
8.6 使用schedule With Fixed Delay()方法实现周期性执行 248 
8.7 使用get Queue()与remove()方法 250 
8.8 方法set Execute Existing Delayed Tasks After Shutdown Policy()的使用 253 
8.9 方法set Continue Existing Periodic Tasks After Shutdown Policy() 255 
8.10 使用cancel(boolean)与set Remove On Cancel Policy()方法 257 
8.11 本章总结 261 
第9章 Fork—Join分治编程 262 
9.1 Fork—Join分治编程与类结构 262 
9.2 使用Recursive Action让任务跑起来 264 
9.3 使用Recursive Action分解任务 265 
9.4 使用Recursive Task取得返回值与join()和get()方法的区别 266 
9.5 使用Recursive Task执行多个任务并打印返回值 270 
9.6 使用Recursive Task实现字符串累加 272 
9.7 使用Fork—Join实现求和:实验1273 
9.8 使用Fork—Join实现求和:实验2275 
9.9 类ForkJoin Pool核心方法的实验 276 
9.9.1 方法public void execute(Fork Join Task task)的使用 276 
9.9.2 方法public void execute(Runnable task)的使用 278 
9.9.3 方法public void execute(Fork Join Task task)如何处理返回值 278 
9.9.4 方法public Fork Join Task submit(ForkJoinTask task)的使用 279 
9.9.5 方法public Fork Join Task submit(Runnable task)的使用 280 
9.9.6 方法public Fork Join Task submit(Callable task)的使用 281 
9.9.7 方法public Fork Join Task submit(Runnable task, T result)的使用 282 
9.9.8 方法public List> invoke All(Collection> tasks)的使用 285 
9.9.9 方法public void shutdown()的使用 286 
9.9.10 方法public List shutdown Now()的使用 289 
9.9.11 方法is Terminating()和is Terminated()的使用 292 
9.9.12 方法public boolean is Shutdown()的使用 295 
9.9.13 方法public boolean await Termination(long timeout, Time Unit unit)的使用 297 
9.9.14 方法public T invoke(Fork Join Task task)的使用 299 
9.9.15 监视pool池的状态 301 
9.10 类Fork Join Task对异常的处理 308 
9.11 本章总结 309 
第10章 并发集合框架 310 
10.1 集合框架结构简要 310 
10.1.1 接口Iterable 310 
10.1.2 接口Collection 311 
10.1.3 接口List 311 
10.1.4 接口Set 312 
10.1.5 接口Queue 312 
10.1.6 接口Deque 312 
10.2 非阻塞队列 313 
10.2.1 类Concurrent Hash Map的使用 313 
10.2.2 类Concurrent Skip List Map的使用 322 
10.2.3 类Concurrent Skip List Set的使用 325 
10.2.4 类Concurrent Linked Queue的使用 328 
10.2.5 类Concurrent Linked Deque的使用 330 
10.2.6 类Copy On Write Array List的使用 332 
10.2.7 类Copy On Write Array Set的使用 335 
10.3 阻塞队列 337 
10.3.1 类Array Blocking Queue的使用 337 
10.3.2 类Priority Blocking Queue的使用 338 
10.3.3 类Linked Blocking Queue的使用 340 
10.3.4 类Linked Blocking Deque的使用 341 
10.3.5 类Synchronous Queue的使用 341 
10.3.6 类Delay Queue的使用 344 
10.3.7 类Linked Transfer Queue的使用 345 
10.4 本章总结 354

我来说两句

本书评论

共有 0 条评论
图书分类
我的书库手机端
帮助中心
会员登录 ×
新用户注册 ×