摘要:
volatile的使用条件-volatile变量的值独立于其他变量和它本身以前的值。 阅读全文
摘要:
最近在看dom scripting这本书,这本书里面针对javascript提出了三条最佳实践的观点。1.Graceful degradation: ensuring that your web pages still work without JavaScript. 优雅降级,就是我们在使用javascript时要考虑到客户端可能不会支持javascript。基于这一点,我们在编写web程序时就要保证即使客户端不支持javascript,也能访问页面的主要内容。这种访问可能体验不太好,但是不会影响用户正常使用。2.Unobtrusive JavaScript: separating stru 阅读全文
摘要:
Guarded Blocks保护块Threads often have to coordinate their actions. The most common coordination idiom is the guarded 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.线程经常必须协调他们的活动。最普通的协 阅读全文
摘要:
Deadlock 死锁Deadlock describes a situation where two or more threads are blocked forever, waiting for each other. Here's an example.死锁就是俩个或多个线程互相等待造成永远被阻塞的状况。这里有一个例子Alphonse and Gaston are friends, and great believers in courtesy. A strict rule of courtesy is that when you bow to a friend, you mu 阅读全文
摘要:
Atomic Access原子访问In programming, an atomic action 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.在编程中,一个原子操作只有效地发生一次。一 阅读全文
摘要:
Intrinsic Locks and Synchronization内置锁和同步Synchronization is built around an internal entity known as the intrinsic lock or monitor lock. (The API specification often refers to this entity simply as a "monitor.") Intrinsic locks play a role in both aspects of synchronization: enforcing excl 阅读全文
摘要:
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.java编程语句提供了2种基本的同步习语( 阅读全文
摘要:
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 understandin 阅读全文
摘要:
Thread Interference线程冲突Consider a simple class called Counter考虑一个称作Counter的类class Counter { private int c = 0; public void increment() { c++; } public void decrement() { c--; } public int value() { return c; }}Counter is designed so that each invocation of i... 阅读全文
摘要:
Interrupts中断An interrupt is 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.中断表明 阅读全文