随笔分类 - java
摘要:volatile的使用条件-volatile变量的值独立于其他变量和它本身以前的值。
阅读全文
摘要: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.中断表明
阅读全文
摘要:Pausing Execution with Sleep用睡眠(Sleep)暂停执行(Execution)Thread.sleep causes 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 syst
阅读全文
摘要:Thread Objects线程对象Each thread is associated with an instance of the class Thread. There are two basic strategies for using Thread objects to create a concurrent application.每个线程都与线程类的实例有关。使用线程对象创建同步应用程序有俩个基本的策略To directly control thread creation and management, simply instantiate Thread each time th
阅读全文
摘要:Processes and Threads进程和线程In concurrent programming, there are two basic units of execution: processes and threads. In the Java programming language, concurrent programming is mostly concerned with threads. However, processes are also important.在并发编程中,有2个基本的执行单元:进程和线程。在java编程语言中,并发编程通常比较关心线程。然而进程也是非
阅读全文
浙公网安备 33010602011771号