摘要: Concurrent CollectionsThejava.util.concurrentpackage includes a number of additions to the Java Collections Framework. These are most easily categorized by the collection interfaces provided:BlockingQueuedefines a first-in-first-out data structure that blocks or times out when you attempt to add to 阅读全文
posted @ 2013-09-08 01:01 alexander.bruce.lee 阅读(764) 评论(0) 推荐(0)
摘要: Fork/JoinThis section was updated to reflect features and conventions of the upcoming Java SE 8 release. You can download the currentJDK 8 snapshotfromjava.net.The fork/join framework is an implementation of theExecutorServiceinterface that helps you take advantage of multiple processors. It is desi 阅读全文
posted @ 2013-09-06 01:23 alexander.bruce.lee 阅读(1255) 评论(0) 推荐(1)
摘要: Thread PoolsMost of the executor implementations injava.util.concurrentusethread pools, which consist ofworker threads. This kind of thread exists separately from theRunnableandCallabletasks it executes and is often used to execute multiple tasks.Using worker threads minimizes the overhead due to th 阅读全文
posted @ 2013-09-05 00:16 alexander.bruce.lee 阅读(622) 评论(0) 推荐(0)
摘要: ExecutorsIn all of the previous examples, there's a close connection between the task being done by a new thread, as defined by itsRunnableobject, and the thread itself, as defined by aThreadobject. This works well for small applications, but in large-scale applications, it makes sense to separa 阅读全文
posted @ 2013-08-31 21:08 alexander.bruce.lee 阅读(1284) 评论(0) 推荐(0)
摘要: Lock ObjectsSynchronized code relies on a simple kind of reentrant lock. This kind of lock is easy to use, but has many limitations. More sophisticated locking idioms are supported by thejava.util.concurrent.lockspackage. We won't examine this package in detail, but instead will focus on its mos 阅读全文
posted @ 2013-08-27 23:43 alexander.bruce.lee 阅读(849) 评论(0) 推荐(0)
摘要: High Level Concurrency ObjectsSo far, this lesson has focused on the low-level APIs that have been part of the Java platform from the very beginning. These APIs are adequate for very basic tasks, but higher-level building blocks are needed for more advanced tasks. This is especially true for massive 阅读全文
posted @ 2013-08-27 00:48 alexander.bruce.lee 阅读(1032) 评论(0) 推荐(0)
摘要: A Strategy for Defining Immutable ObjectsThe following rules define a simple strategy for creating immutable objects. Not all classes documented as "immutable" follow these rules. This does not necessarily mean the creators of these classes were sloppy — they may have good reason for belie 阅读全文
posted @ 2013-08-26 01:08 alexander.bruce.lee 阅读(1018) 评论(0) 推荐(0)
摘要: Immutable ObjectsAn object is consideredimmutableif its state cannot change after it is constructed. Maximum reliance on immutable objects is widely accepted as a sound strategy for creating simple, reliable code.Immutable objects are particularly useful in concurrent applications. Since they cannot 阅读全文
posted @ 2013-08-19 01:18 alexander.bruce.lee 阅读(862) 评论(0) 推荐(0)
摘要: 2013-08-1323:32:30乘情人节还没有过去,作为一个屌丝程序员,从来没有过过情人节。不过我们也有自己的乐趣,这个时候貌似只有海子的《面朝大海》能够啊Q式慰藉自己。不多说了,早上上班的时候看到google首页,就感觉很有爱,不过当时没怎么玩,只是点点了,听听背景音乐,感觉甚好。话说作为程序员,看看国内某著名搜索引擎的情况就显得捉襟见肘了。咱没鄙视它的权利,没准它还会鄙视我等屌丝程序员,有zf支持,能赚钱才是硬道理啊!作为屌丝程序员还是先玩玩谷歌的小游戏,不为搜索,只想玩玩,呵呵,谁叫咱单身屌丝。上传几张图片,祝福哪些牛郎、织女们!!!firstsecondthird.作为成员员,怎么 阅读全文
posted @ 2013-08-13 23:52 alexander.bruce.lee 阅读(1699) 评论(7) 推荐(0)
摘要: Guarded BlocksThreads often have to coordinate their actions. The most common coordination idiom is theguarded block. Such a block begins by polling a condition that must be true before the block can proceed. There are a number of steps to follow in order to do this correctly.Suppose, for examplegua 阅读全文
posted @ 2013-08-06 00:05 alexander.bruce.lee 阅读(813) 评论(0) 推荐(0)