摘要:
在java中要想实现多线程,有两种手段,一种是继续Thread类,另外一种是实现Runable接口。 对于直接继承Thread的类来说,代码大致框架是: 先看一个简单的例子: 【运行结果】:A运行 0 A运行 1 A运行 2 A运行 3 A运行 4 B运行 0 B运行 1 B运行 2 B运行 3 B 阅读全文
摘要:
/** * @author Rollen-Holt 设计模式之 代理模式 */ interface NetWork{ public abstract void browser(); } /** * Real 类代表用户上网的实际动作,比如查看网页 * */ class Real implements NetWork{ public void browser(){ ... 阅读全文