在好例子网,分享、交流、成长!
您当前所在位置:首页Java 开发实例Java语言基础 → Java Threads, Third Edition

Java Threads, Third Edition

Java语言基础

下载此实例
  • 开发语言:Java
  • 实例大小:2.46M
  • 下载次数:10
  • 浏览次数:42
  • 发布时间:2022-10-26
  • 实例类别:Java语言基础
  • 发 布 人:{Z}
  • 文件格式:.pdf
  • 所需积分:2
 相关标签:

实例介绍

【实例简介】Java Threads, Third Edition

【实例截图】

【核心代码】

Table Of Contents
1. Java Threads, Third Edition .............................................................................................................. 5
2. Table of Contents ............................................................................................................................. 5
3. Copyright ......................................................................................................................................... 8
4. Preface ............................................................................................................................................. 9
4.1 Who Should Read This Book? .............................................................................................. 10
4.2 Versions Used in This Book .................................................................................................. 10
4.3 What's New in This Edition? ................................................................................................ 11
4.4 Organization of This Book .................................................................................................... 13
4.5 Conventions Used in This Book ............................................................................................ 15
4.6 Code Examples ..................................................................................................................... 16
4.7 How to Contact Us ............................................................................................................... 16
4.8 Safari Enabled ...................................................................................................................... 17
4.9 Acknowledgments ............................................................................................................... 17
5. Chapter 1. Introduction to Threads ............................................................................................... 18
5.1 1.1 Java Terms ...................................................................................................................... 18
5.2 1.2 About the Examples ....................................................................................................... 21
5.3 1.3 Why Threads? ................................................................................................................ 24
5.4 1.4 Summary ........................................................................................................................ 28
6. Chapter 2. Thread Creation and Management .............................................................................. 29
6.1 2.1 What Is a Thread? .......................................................................................................... 29
6.2 2.2 Creating a Thread ........................................................................................................... 33
6.3 2.3 The Lifecycle of a Thread ............................................................................................... 48
6.4 2.4 Two Approaches to Stopping a Thread .......................................................................... 53
6.5 2.5 The Runnable Interface .................................................................................................. 58
6.6 2.6 Threads and Objects ...................................................................................................... 65
6.7 2.7 Summary ........................................................................................................................ 67
7. Chapter 3. Data Synchronization ................................................................................................... 69
7.1 3.1 The Synchronized Keyword ............................................................................................ 69
7.2 3.2 The Volatile Keyword ..................................................................................................... 73
7.3 3.3 More on Race Conditions .............................................................................................. 76
7.4 3.4 Explicit Locking ............................................................................................................... 84
7.5 3.5 Lock Scope ..................................................................................................................... 89
7.6 3.6 Choosing a Locking Mechanism ..................................................................................... 94
7.7 3.7 Nested Locks .................................................................................................................. 96
7.8 3.8 Deadlock ...................................................................................................................... 100
7.9 3.9 Lock Fairness ................................................................................................................ 109
7.10 3.10 Summary .................................................................................................................. 111
8. Chapter 4. Thread Notification .................................................................................................... 112
8.1 4.1 Wait and Notify ............................................................................................................ 113
8.2 4.2 Condition Variables ...................................................................................................... 123
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
2
8.3 4.3 Summary ...................................................................................................................... 128
9. Chapter 5. Minimal Synchronization Techniques......................................................................... 129
9.1 5.1 Can You Avoid Synchronization? .................................................................................. 130
9.2 5.2 Atomic Variables .......................................................................................................... 136
9.3 5.3 Thread Local Variables ................................................................................................. 168
9.4 5.4 Summary ...................................................................................................................... 171
10. Chapter 6. Advanced Synchronization Topics ............................................................................ 172
10.1 6.1 Synchronization Terms ............................................................................................... 173
10.2 6.2 Synchronization Classes Added in J2SE 5.0 ................................................................ 174
10.3 6.3 Preventing Deadlock .................................................................................................. 182
10.4 6.4 Deadlock Detection ................................................................................................... 190
10.5 6.5 Lock Starvation .......................................................................................................... 211
10.6 6.6 Summary .................................................................................................................... 216
11. Chapter 7. Threads and Swing ................................................................................................... 217
11.1 7.1 Swing Threading Restrictions ..................................................................................... 217
11.2 7.2 Processing on the Event-Dispatching Thread ............................................................ 218
11.3 7.3 Using invokeLater( ) and invokeAndWait( ) ................................................................ 219
11.4 7.4 Long-Running Event Callbacks ................................................................................... 222
11.5 7.5 Summary .................................................................................................................... 227
12. Chapter 8. Threads and Collection Classes ................................................................................ 228
12.1 8.1 Overview of Collection Classes .................................................................................. 229
12.2 8.2 Synchronization and Collection Classes ..................................................................... 234
12.3 8.3 The Producer/Consumer Pattern ............................................................................... 245
12.4 8.4 Using the Collection Classes ...................................................................................... 249
12.5 8.5 Summary .................................................................................................................... 250
13. Chapter 9. Thread Scheduling .................................................................................................... 251
13.1 9.1 An Overview of Thread Scheduling ............................................................................ 252
13.2 9.2 Scheduling with Thread Priorities .............................................................................. 262
13.3 9.3 Popular Threading Implementations ......................................................................... 264
13.4 9.4 Summary .................................................................................................................... 272
14. Chapter 10. Thread Pools .......................................................................................................... 273
14.1 10.1 Why Thread Pools? .................................................................................................. 273
14.2 10.2 Executors ................................................................................................................. 277
14.3 10.3 Using a Thread Pool ................................................................................................. 279
14.4 10.4 Queues and Sizes ..................................................................................................... 282
14.5 10.5 Thread Creation ....................................................................................................... 287
14.6 10.6 Callable Tasks and Future Results ............................................................................ 288
14.7 10.7 Single-Threaded Access ........................................................................................... 291
14.8 10.8 Summary .................................................................................................................. 293
15. Chapter 11. Task Scheduling ...................................................................................................... 294
15.1 11.1 Overview of Task Scheduling ................................................................................... 295
15.2 11.2 The java.util.Timer Class .......................................................................................... 296
15.3 11.3 The javax.swing.Timer Class ..................................................................................... 307
15.4 11.4 The ScheduledThreadPoolExecutor Class ................................................................ 312
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
3
15.5 11.5 Summary .................................................................................................................. 322
16. Chapter 12. Threads and I/O ..................................................................................................... 324
16.1 12.1 A Traditional I/O Server ........................................................................................... 325
16.2 12.2 A New I/O Server ..................................................................................................... 343
16.3 12.3 Interrupted I/O ........................................................................................................ 360
16.4 12.4 Summary .................................................................................................................. 365
17. Chapter 13. Miscellaneous Thread Topics ................................................................................. 367
17.1 13.1 Thread Groups ......................................................................................................... 367
17.2 13.2 Threads and Java Security ........................................................................................ 369
17.3 13.3 Daemon Threads ...................................................................................................... 372
17.4 13.4 Threads and Class Loading ....................................................................................... 373
17.5 13.5 Threads and Exception Handling ............................................................................. 374
17.6 13.6 Threads, Stacks, and Memory Usage ....................................................................... 379
17.7 13.7 Summary .................................................................................................................. 384
18. Chapter 14. Thread Performance .............................................................................................. 384
18.1 14.1 Overview of Performance ........................................................................................ 385
18.2 14.2 Synchronized Collections ......................................................................................... 387
18.3 14.3 Atomic Variables and Contended Synchronization .................................................. 389
18.4 14.4 Thread Creation and Thread Pools .......................................................................... 391
18.5 14.5 Summary .................................................................................................................. 392
19. Chapter 15. Parallelizing Loops for Multiprocessor Machines .................................................. 393
19.1 15.1 Parallelizing a Single-Threaded Program ................................................................. 394
19.2 15.2 Multiprocessor Scaling ............................................................................................. 437
19.3 15.3 Summary .................................................................................................................. 456
20. Appendix A. Superseded Threading Utilities ............................................................................. 458
20.1 A.1 The BusyFlag Class ..................................................................................................... 459
20.2 A.2 The CondVar Class ..................................................................................................... 461
20.3 A.3 The Barrier Class ........................................................................................................ 467
20.4 A.4 The RWLock Class ...................................................................................................... 469
20.5 A.5 The ThreadPool Class................................................................................................. 475
20.6 A.6 The JobScheduler Class ............................................................................................. 482
20.7 A.7 Summary ................................................................................................................... 492
21. Colophon ................................................................................................................................... 493
22. Index .......................................................................................................................................... 494
22.1 index_A ............................................................................................................................ 494
22.2 index_B ............................................................................................................................ 495
22.3 index_C ............................................................................................................................ 496
22.4 index_D ............................................................................................................................ 498
22.5 index_E ............................................................................................................................ 498
22.6 index_F ............................................................................................................................ 499
22.7 index_G ............................................................................................................................ 500
22.8 index_H ............................................................................................................................ 500
22.9 index_I ............................................................................................................................. 501
22.10 index_J ........................................................................................................................... 502
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
4
22.11 index_K .......................................................................................................................... 503
22.12 index_L ........................................................................................................................... 503
22.13 index_M ......................................................................................................................... 505
22.14 index_N .......................................................................................................................... 509
22.15 index_O .......................................................................................................................... 509
22.16 index_P .......................................................................................................................... 510
22.17 index_Q .......................................................................................................................... 511
22.18 index_R .......................................................................................................................... 511
22.19 index_S .......................................................................................................................... 512
22.20 index_T .......................................................................................................................... 515
22.21 index_U .......................................................................................................................... 517
22.22 index_V .......................................................................................................................... 518
22.23 index_W ......................................................................................................................... 519
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
5
1. Java Threads, Third Edition
• Table of Contents(See 2.)
• Index(See 22.)
• Reviews
• Reader Reviews
• Errata
• Academic
Java Threads, Third Edition
By Scott Oaks , Henry Wong
Publisher : O'Reilly
Pub Date : September 2004
ISBN : 0-596-00782-5
Pages : 360
Threads are essential to Java programming, but learning to use them effectively is a
nontrivial task. This new edition of the classic Java Threads shows you how to take full
advantage of Java's threading facilities and brings you up-to-date with the watershed
changes in Java 2 Standard Edition version 5.0 (J2SE 5.0). It provides a thorough,
step-by-step approach to threads programming.
2. Table of Contents
• Index(See 22.)
• Reviews
• Reader Reviews
• Errata
• Academic
Java Threads, Third Edition
By Scott Oaks , Henry Wong
Publisher : O'Reilly
Pub Date : September 2004
ISBN : 0-596-00782-5
Pages : 360
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
6
Copyright(See 3.)
Preface(See 4.)
Who Should Read This Book?(See 4.1)
Versions Used in This Book(See 4.2)
What's New in This Edition?(See 4.3)
Organization of This Book(See 4.4)
Conventions Used in This Book(See 4.5)
Code Examples(See 4.6)
How to Contact Us(See 4.7)
Safari Enabled(See 4.8)
Acknowledgments(See 4.9)
Chapter 1. Introduction to Threads(See 5.)
Section 1.1. Java Terms(See 5.1)
Section 1.2. About the Examples(See 5.2)
Section 1.3. Why Threads?(See 5.3)
Section 1.4. Summary(See 5.4)
Chapter 2. Thread Creation and Management(See 6.)
Section 2.1. What Is a Thread?(See 6.1)
Section 2.2. Creating a Thread(See 6.2)
Section 2.3. The Lifecycle of a Thread(See 6.3)
Section 2.4. Two Approaches to Stopping a Thread(See 6.4)
Section 2.5. The Runnable Interface(See 6.5)
Section 2.6. Threads and Objects(See 6.6)
Section 2.7. Summary(See 6.7)
Chapter 3. Data Synchronization(See 7.)
Section 3.1. The Synchronized Keyword(See 7.1)
Section 3.2. The Volatile Keyword(See 7.2)
Section 3.3. More on Race Conditions(See 7.3)
Section 3.4. Explicit Locking(See 7.4)
Section 3.5. Lock Scope(See 7.5)
Section 3.6. Choosing a Locking Mechanism(See 7.6)
Section 3.7. Nested Locks(See 7.7)
Section 3.8. Deadlock(See 7.8)
Section 3.9. Lock Fairness(See 7.9)
Section 3.10. Summary(See 7.10)
Chapter 4. Thread Notification(See 8.)
Section 4.1. Wait and Notify(See 8.1)
Section 4.2. Condition Variables(See 8.2)
Section 4.3. Summary(See 8.3)
Chapter 5. Minimal Synchronization Techniques(See 9.)
Section 5.1. Can You Avoid Synchronization?(See 9.1)
Section 5.2. Atomic Variables(See 9.2)
Section 5.3. Thread Local Variables(See 9.3)
Section 5.4. Summary(See 9.4)
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
7
Chapter 6. Advanced Synchronization Topics(See 10.)
Section 6.1. Synchronization Terms(See 10.1)
Section 6.2. Synchronization Classes Added in J2SE 5.0(See 10.2)
Section 6.3. Preventing Deadlock(See 10.3)
Section 6.4. Deadlock Detection(See 10.4)
Section 6.5. Lock Starvation(See 10.5)
Section 6.6. Summary(See 10.6)
Chapter 7. Threads and Swing(See 11.)
Section 7.1. Swing Threading Restrictions(See 11.1)
Section 7.2. Processing on the Event-Dispatching Thread(See 11.2)
Section 7.3. Using invokeLater( ) and invokeAndWait( )(See 11.3)
Section 7.4. Long-Running Event Callbacks(See 11.4)
Section 7.5. Summary(See 11.5)
Chapter 8. Threads and Collection Classes(See 12.)
Section 8.1. Overview of Collection Classes(See 12.1)
Section 8.2. Synchronization and Collection Classes(See 12.2)
Section 8.3. The Producer/Consumer Pattern(See 12.3)
Section 8.4. Using the Collection Classes(See 12.4)
Section 8.5. Summary(See 12.5)
Chapter 9. Thread Scheduling(See 13.)
Section 9.1. An Overview of Thread Scheduling(See 13.1)
Section 9.2. Scheduling with Thread Priorities(See 13.2)
Section 9.3. Popular Threading Implementations(See 13.3)
Section 9.4. Summary(See 13.4)
Chapter 10. Thread Pools(See 14.)
Section 10.1. Why Thread Pools?(See 14.1)
Section 10.2. Executors(See 14.2)
Section 10.3. Using a Thread Pool(See 14.3)
Section 10.4. Queues and Sizes(See 14.4)
Section 10.5. Thread Creation(See 14.5)
Section 10.6. Callable Tasks and Future Results(See 14.6)
Section 10.7. Single-Threaded Access(See 14.7)
Section 10.8. Summary(See 14.8)
Chapter 11. Task Scheduling(See 15.)
Section 11.1. Overview of Task Scheduling(See 15.1)
Section 11.2. The java.util.Timer Class(See 15.2)
Section 11.3. The javax.swing.Timer Class(See 15.3)
Section 11.4. The ScheduledThreadPoolExecutor Class(See 15.4)
Section 11.5. Summary(See 15.5)
Chapter 12. Threads and I/O(See 16.)
Section 12.1. A Traditional I/O Server(See 16.1)
Section 12.2. A New I/O Server(See 16.2)
Section 12.3. Interrupted I/O(See 16.3)
Section 12.4. Summary(See 16.4)
更多IT编程类电子书尽在:https://shop109847659.taobao.com/或者加微信w33311w免费领取
Java Threads, Third Edition
8
Chapter 13. Miscellaneous Thread Topics(See 17.)
Section 13.1. Thread Groups(See 17.1)
Section 13.2. Threads and Java Security(See 17.2)
Section 13.3. Daemon Threads(See 17.3)
Section 13.4. Threads and Class Loading(See 17.4)
Section 13.5. Threads and Exception Handling(See 17.5)
Section 13.6. Threads, Stacks, and Memory Usage(See 17.6)
Section 13.7. Summary(See 17.7)
Chapter 14. Thread Performance(See 18.)
Section 14.1. Overview of Performance(See 18.1)
Section 14.2. Synchronized Collections(See 18.2)
Section 14.3. Atomic Variables and Contended Synchronization(See 18.3)
Section 14.4. Thread Creation and Thread Pools(See 18.4)
Section 14.5. Summary(See 18.5)
Chapter 15. Parallelizing Loops for Multiprocessor Machines(See 19.)
Section 15.1. Parallelizing a Single-Threaded Program(See 19.1)
Section 15.2. Multiprocessor Scaling(See 19.2)
Section 15.3. Summary(See 19.3)
Appendix A. Superseded Threading Utilities(See 20.)
Section A.1. The BusyFlag Class(See 20.1)
Section A.2. The CondVar Class(See 20.2)
Section A.3. The Barrier Class(See 20.3)
Section A.4. The RWLock Class(See 20.4)
Section A.5. The ThreadPool Class(See 20.5)
Section A.6. The JobScheduler Class(See 20.6)
Section A.7. Summary(See 20.7)
Colophon(See 21.)
Index(See 22.

标签:

实例下载地址

Java Threads, Third Edition

不能下载?内容有错? 点击这里报错 + 投诉 + 提问

好例子网口号:伸出你的我的手 — 分享

网友评论

发表评论

(您的评论需要经过审核才能显示)

查看所有0条评论>>

小贴士

感谢您为本站写下的评论,您的评论对其它用户来说具有重要的参考价值,所以请认真填写。

  • 类似“顶”、“沙发”之类没有营养的文字,对勤劳贡献的楼主来说是令人沮丧的反馈信息。
  • 相信您也不想看到一排文字/表情墙,所以请不要反馈意义不大的重复字符,也请尽量不要纯表情的回复。
  • 提问之前请再仔细看一遍楼主的说明,或许是您遗漏了。
  • 请勿到处挖坑绊人、招贴广告。既占空间让人厌烦,又没人会搭理,于人于己都无利。

关于好例子网

本站旨在为广大IT学习爱好者提供一个非营利性互相学习交流分享平台。本站所有资源都可以被免费获取学习研究。本站资源来自网友分享,对搜索内容的合法性不具有预见性、识别性、控制性,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,平台无法对用户传输的作品、信息、内容的权属或合法性、安全性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论平台是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二与二十三条之规定,若资源存在侵权或相关问题请联系本站客服人员,点此联系我们。关于更多版权及免责申明参见 版权及免责申明

;
报警