随笔分类 -  java

摘要: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 阅读(847) 评论(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 阅读(1026) 评论(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 阅读(1012) 评论(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 阅读(859) 评论(0) 推荐(0)
摘要:2013-08-1323:32:30乘情人节还没有过去,作为一个屌丝程序员,从来没有过过情人节。不过我们也有自己的乐趣,这个时候貌似只有海子的《面朝大海》能够啊Q式慰藉自己。不多说了,早上上班的时候看到google首页,就感觉很有爱,不过当时没怎么玩,只是点点了,听听背景音乐,感觉甚好。话说作为程序员,看看国内某著名搜索引擎的情况就显得捉襟见肘了。咱没鄙视它的权利,没准它还会鄙视我等屌丝程序员,有zf支持,能赚钱才是硬道理啊!作为屌丝程序员还是先玩玩谷歌的小游戏,不为搜索,只想玩玩,呵呵,谁叫咱单身屌丝。上传几张图片,祝福哪些牛郎、织女们!!!firstsecondthird.作为成员员,怎么 阅读全文
posted @ 2013-08-13 23:52 alexander.bruce.lee 阅读(1696) 评论(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 阅读(804) 评论(0) 推荐(0)
摘要:Starvation and LivelockStarvation and livelock are much less common a problem than deadlock, but are still problems that every designer of concurrent software is likely to encounter.StarvationStarvationdescribes a situation where a thread is unable to gain regular access to shared resources and is u 阅读全文
posted @ 2013-08-03 23:19 alexander.bruce.lee 阅读(1306) 评论(0) 推荐(0)
摘要:A concurrent application's ability to execute in a timely manner is known as itsliveness. This section describes the most common kind of liveness problem,deadlock, and goes on to briefly describe two other liveness problems,starvation and livelock.译文: 一个并发应用程序在时间上的执行的能力被称为活动性。这一节主要描述了活动性的问题,死锁,并 阅读全文
posted @ 2013-08-01 22:32 alexander.bruce.lee 阅读(381) 评论(0) 推荐(0)
摘要:Atomic AccessIn programming, anatomicaction is one that effectively happens all at once. An atomic action cannot stop in the middle: it either happens completely, or it doesn't happen at all. No side effects of an atomic action are visible until the action is complete.We have already seen that a 阅读全文
posted @ 2013-07-21 17:32 alexander.bruce.lee 阅读(771) 评论(0) 推荐(0)
摘要:Intrinsic Locks and SynchronizationSynchronization is built around an internal entity known as theintrinsic lockormonitor lock. (The API specification often refers to this entity simply as a "monitor.") Intrinsic locks play a role in both aspects of synchronization: enforcing exclusive acc 阅读全文
posted @ 2013-07-15 22:59 alexander.bruce.lee 阅读(352) 评论(0) 推荐(0)
摘要:Synchronized Methods The Java programming language provides two basic synchronization idioms: synchronized methods and synchronized statements. The more complex of the two, synchronized statements, are described in the next section. This section is about synchronized methods. To make a method sync.. 阅读全文
posted @ 2013-07-15 12:05 alexander.bruce.lee 阅读(663) 评论(0) 推荐(1)
摘要:Memory Consistency Errors Memory consistency errors occur when different threads have inconsistent views of what should be the same data. The causes of memory consistency errors are complex and beyond the scope of this tutorial. Fortunately, the programmer does not need a detailed understanding of . 阅读全文
posted @ 2013-07-14 21:09 alexander.bruce.lee 阅读(807) 评论(0) 推荐(0)
摘要:SynchronizationThreads communicate primarily by sharing access to fields and the objects reference fields refer to. This form of communication is extremely efficient, but makes two kinds of errors possible:thread interferenceandmemory consistency errors. The tool needed to prevent these errors issyn 阅读全文
posted @ 2013-07-11 11:19 alexander.bruce.lee 阅读(383) 评论(0) 推荐(0)
摘要:JoinsThejoinmethod allows one thread to wait for the completion of another. Iftis aThreadobject whose thread is currently executing,t.join();causes the current thread to pause execution untilt's thread terminates. Overloads ofjoinallow the programmer to specify a waiting period. However, as with 阅读全文
posted @ 2013-07-09 13:03 alexander.bruce.lee 阅读(779) 评论(0) 推荐(1)
摘要:InterruptsAninterruptis an indication to a thread that it should stop what it is doing and do something else. It's up to the programmer to decide exactly how a thread responds to an interrupt, but it is very common for the thread to terminate. This is the usage emphasized in this lesson.A thread 阅读全文
posted @ 2013-07-06 15:34 alexander.bruce.lee 阅读(700) 评论(0) 推荐(0)
摘要:Pausing Execution with SleepThread.sleepcauses the current thread to suspend execution for a specified period. This is an efficient means of making processor time available to the other threads of an application or other applications that might be running on a computer system. Thesleepmethod can als 阅读全文
posted @ 2013-06-28 20:57 alexander.bruce.lee 阅读(901) 评论(0) 推荐(0)
摘要:Thread ObjectsEach thread is associated with an instance of the classThread. There are two basic strategies for usingThreadobjects to create a concurrent application.To directly control thread creation and management, simply instantiateThreadeach time the application needs to initiate an asynchronou 阅读全文
posted @ 2013-06-26 21:55 alexander.bruce.lee 阅读(317) 评论(0) 推荐(0)
摘要:Processes and ThreadsIn concurrent programming, there are two basic units of execution:processesandthreads. In the Java programming language, concurrent programming is mostly concerned with threads. However, processes are also important.A computer system normally has many active processes and thread 阅读全文
posted @ 2013-06-21 21:16 alexander.bruce.lee 阅读(629) 评论(0) 推荐(0)
摘要:Lesson: ConcurrencyComputer users take it for granted that their systems can do more than one thing at a time. They assume that they can continue to work in a word processor, while other applications download files, manage the print queue, and stream audio. Even a single application is often expecte 阅读全文
posted @ 2013-06-20 00:21 alexander.bruce.lee 阅读(277) 评论(0) 推荐(0)