定义线程
实现线程的方式,上一章中已经提到。下面使用实现Runnable的方式
/**
* Created by 侯彬彬 on 2016/4/14.
*/
public class NumCounter implements Runnable {
private static int count = 0;
private final int id = coun...
Thread
In concurrent programming, there are two basic units of execution: processes and threads.
A process has a self-contained execution environment. Threads are sometimes called lightweight proc...
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 bloc...