没有合适的资源?快使用搜索试试~ 我知道了~
首页Concurrent+Programming+in+Java+-+Design+Principles+and+Patterns,+Second+Edition_
资源详情
资源评论
资源推荐
Concurrent Programming in Java™:
Design Principles and Patterns,
Second Edition
cpj
1
Table Of Contents
Table Of Contents ................................................................................................................................ 1
1. Chapter 1. Concurrent Object-Oriented Programming................................................................. 2
1.1 Section 1.1. Using Concurrency Constructs ........................................................................ 5
1.2 Section 1.2. Objects and Concurrency .............................................................................. 17
1.3 Section 1.3. Design Forces ................................................................................................ 31
1.4 Section 1.4. Before/After Patterns .................................................................................... 47
2. Chapter 2. Exclusion ................................................................................................................... 57
2.1 Section 2.1. Immutability .................................................................................................. 58
2.2 Section 2.2. Synchronization............................................................................................. 62
2.3 Section 2.3. Confinement ................................................................................................. 83
2.4 Section 2.4. Structuring and Refactoring Classes.............................................................. 99
2.5 Section 2.5. Using Lock Utilities ...................................................................................... 125
3. Chapter 3. State Dependence ................................................................................................... 137
3.1 Section 3.1. Dealing with Failure .................................................................................... 138
3.2 Section 3.2. Guarded Methods ....................................................................................... 153
3.3 Section 3.3. Structuring and Refactoring Classes............................................................ 171
3.4 Section 3.4. Using Concurrency Control Utilities ............................................................ 189
3.5 Section 3.5. Joint Actions ................................................................................................ 204
3.6 Section 3.6. Transactions ................................................................................................ 215
3.7 Section 3.7. Implementing Utilities ................................................................................ 228
4. Chapter 4. Creating Threads ..................................................................................................... 242
4.1 Section 4.1. Oneway Messages ....................................................................................... 245
4.2 Section 4.2. Composing Oneway Messages .................................................................... 262
4.3 Section 4.3. Services in Threads ..................................................................................... 281
4.4 Section 4.4. Parallel Decomposition ............................................................................... 298
4.5 Section 4.5. Active Objects ............................................................................................. 320
cpj
2
1. Chapter 1. Concurrent Object-Oriented
Programming
This book discusses some ways of thinking about, designing, and implementing concurrent programs in the Java™
programming language. Most presentations in this book assume that you are an experienced developer familiar
with object-oriented (OO) programming, but have little exposure to concurrency. Readers with the opposite
background — experience with concurrency in other languages — may also find this book useful.
The book is organized into four coarse-grained chapters. (Perhaps parts would be a better term.) This first chapter
begins with a brief tour of some frequently used constructs and then backs up to establish a conceptual basis for
concurrent object-oriented programming: how concurrency and objects fit together, how the resulting design forces
impact construction of classes and components, and how some common design patterns can be used to structure
solutions.
The three subsequent chapters are centered around use (and evasion) of the three kinds of concurrency constructs
found in the Java programming language:
Exclusion. Maintaining consistent states of objects by preventing unwanted interference among concurrent activities,
often using synchronized methods.
State dependence. Triggering, preventing, postponing, or recovering from actions depending on whether objects are in
states in which these actions could or did succeed, sometimes using monitor methods Object.wait,
Object.notify, and Object.notifyAll.
Creating threads. Establishing and managing concurrency, using Thread objects.
Each chapter contains a sequence of major sections, each on an independent topic. They present high-level design
principles and strategies, technical details surrounding constructs, utilities that encapsulate common usages, and
associated design patterns that address particular concurrency problems. Most sections conclude with an annotated set
of further readings providing more information on selected topics. The online supplement to this book contains links to
additional online resources, as well as updates, errata, and code examples. It is accessible via links from:
http://java.sun.com/Series or http://gee.cs.oswego.edu/dl/cpj
If you are already familiar with the basics, you can read this book in the presented order to explore each topic in more
depth. But most readers will want to read this book in various different orders. Because most concurrency concepts and
techniques interact with most others, it is not always possible to understand each section or chapter in complete isolation
from all the others. However, you can still take a breadth-first approach, briefly scanning each chapter (including this one)
before proceeding with more detailed coverage of interest. Many presentations later in the book can be approached after
selectively reading through earlier material indicated by extensive cross-references.
You can practice this now by skimming through the following preliminaries.
cpj
3
Terminology. This book uses standard OO terminological conventions: programs define methods (implementing
operations) and fields (representing attributes) that hold for all instances (objects) of specified classes.
Interactions in OO programs normally revolve around the responsibilities placed upon a client object needing an action
to be performed, and a server object containing the code to perform the action. The terms client and server are used
here in their generic senses, not in the specialized sense of distributed client/server architectures. A client is just any
object that sends a request to another object, and a server is just any object receiving such a request. Most objects play
the roles of both clients and servers. In the usual case where it doesn't matter whether an object under discussion acts
as a client or server or both, it is usually called a host; others that it may in turn interact with are often called helpers or
peers. Also, when discussing invocations of the form obj.msg(arg), the recipient (that is, the object bound to variable
obj) is called the target object.
This book generally avoids dealing with transient facts about particular classes and packages not directly related to
concurrency. And it does not cover details about concurrency control in specialized frameworks such as Enterprise
JavaBeans™ and Servlets. But it does sometimes refer to branded software and trademarked products associated with
the Java™ Platform. The copyright page of this book provides more information.
Code listings. Most techniques and patterns in this book are illustrated by variants of an annoyingly small set of toy
running examples. This is not an effort to be boring, but to be clear. Concurrency constructs are often subtle enough to
get lost in otherwise meaningful examples. Reuse of running examples makes small but critical differences more obvious
by highlighting the main design and implementation issues. Also, the presentations include code sketches and
fragments of classes that illustrate implementation techniques, but are not intended to be complete or even compilable.
These classes are indicated by leading comments in the listings.
Import statements, access qualifiers, and even methods and fields are sometimes omitted from listings when they can
be inferred from context or do not impact relevant functionality. The protected qualifier is used as a default for
non-public features whenever there is no particular reason to restrict subclass access. This emphasizes opportunities for
extensibility in concurrent class design (see § 1.3.4(See 1.3) and § 3.3.3(See 3.3)). Classes by default have no
access qualifier. Sample listings are sometimes formatted in nonstandard ways to keep them together on pages or to
emphasize the main constructions of interest.
The code for all example classes in this book is available from the online supplement. Most techniques and patterns in
this book are illustrated by a single code example showing their most typical forms. The supplement includes additional
examples that demonstrate minor variations, as well as some links to other known usages. It also includes some larger
examples that are more useful to browse and experiment with online than to read as listings.
The supplement provides links to a package, util.concurrent, that contains production-quality versions of utility
classes discussed in this book. This code runs on the Java 2 Platform and has been tested with 1.2.x releases.
Occasional discussions, asides, and footnotes briefly mention changes from previous releases, potential future changes
known at the time of this writing, and a few implementation quirks to watch out for. Check the online supplement for
additional updates.
Diagrams. Standard UML notation is used for interaction and class diagrams (see the Further Readings in § 1.1.3(See
1.1)). The accompanying diagrams (courtesy of Martin Fowler) illustrate the only forms used in this book. Other aspects
of UML notation, methodology, and terminology are not specifically relied on.
cpj
4
Most other diagrams show timethreads in which free-form gray curves trace threads traversing through collections of
objects. Flattened arrowheads represent blocking. Objects are depicted as ovals that sometimes show selected internal
features such as locks, fields, and bits of code. Thin (usually labeled) lines between objects represent relations (normally
references or potential calls) between them. Here's an otherwise meaningless example showing that thread A has
acquired the lock for object X, and is proceeding through some method in object Y that serves as a helper to X. Thread B
is meanwhile somehow blocked while entering some method in object X:
剩余329页未读,继续阅读
tulongwuhen
- 粉丝: 3
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 收起
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
会员权益专享
最新资源
- RTL8188FU-Linux-v5.7.4.2-36687.20200602.tar(20765).gz
- c++校园超市商品信息管理系统课程设计说明书(含源代码) (2).pdf
- 建筑供配电系统相关课件.pptx
- 企业管理规章制度及管理模式.doc
- vb打开摄像头.doc
- 云计算-可信计算中认证协议改进方案.pdf
- [详细完整版]单片机编程4.ppt
- c语言常用算法.pdf
- c++经典程序代码大全.pdf
- 单片机数字时钟资料.doc
- 11项目管理前沿1.0.pptx
- 基于ssm的“魅力”繁峙宣传网站的设计与实现论文.doc
- 智慧交通综合解决方案.pptx
- 建筑防潮设计-PowerPointPresentati.pptx
- SPC统计过程控制程序.pptx
- SPC统计方法基础知识.pptx
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论2