
多线程设计模式
fdsafds
这个作者很懒,什么都没留下…
展开
-
多线程设计模式--single threaded execution
调用线程 [code="java"]public class UserThread extends Thread { private final Gate gate; private final String myname; private final String myaddress; public UserThread(Gate gate, Str...2009-07-08 09:58:02 · 106 阅读 · 0 评论 -
多线程设计模式--two-phase termination
two-phase termination 等待线程执行终止处理再结束线程 [code="java"]public class CountupThread extends Thread { // 计数器的值 private long counter = 0; // 已经送出终止请求则为true private volatile boolean...2009-07-21 17:54:33 · 128 阅读 · 0 评论 -
多线程设计模式 -- futrue --新特性
请求数据线程 [code="java"]public class RequestData implements Callable { @Override public Data call() { // TODO Auto-generated method stub int[] arr = new int[100]; try { Thread.sleep(20...2009-07-21 11:04:10 · 131 阅读 · 0 评论 -
多线程设计模式 -- futrue
数据接口 [code="java"]public interface Data { public abstract String getContent(); }[/code] 真正需要的数据对象 [code="java"]public class RealData implements Data { private final String content; ...2009-07-10 15:29:04 · 112 阅读 · 0 评论 -
多程线设计模式 -- woker thread pattern
工作区(核心) [code="java"]public class Channel { //允许最多请求数 private static final int MAX_REQUEST = 100; //请求容器 private final Request[] requestQueue; private int tail; // 下一个putRequest...2009-07-10 14:42:59 · 114 阅读 · 0 评论 -
多线程设计模式 -- Thread-Per-Message
代理执行类 [code="java"]public class Host { private final Helper helper = new Helper(); public void request(final int count, final char c) { System.out.println(" request(" + count + ...2009-07-10 11:55:41 · 99 阅读 · 0 评论 -
多线程设置模式 -- Read-Write Lock Pattern
//读写锁 [code="java"]public final class ReadWriteLock { private int readingReaders = 0; // (A)...实际正在读取的执行绪数量 private int waitingWriters = 0; // (B)...正在等待写入的执行绪数量 private int writingWri...2009-07-10 11:25:01 · 112 阅读 · 0 评论 -
多线程设计模式 -- ProducerConsumer
放蛋糕的桌子 [code="java"]public class Table { private final String[] buffer; private int tail; /下一个放put的地方 private int head; //下一个放的take地方 private int count; // buffer内的蛋糕数 pu...2009-07-10 10:10:07 · 113 阅读 · 0 评论 -
多线程设计模式 -- balking
balking (不需要的话,就算了吧) //操作数据 [code="java"]public class Data { private String filename; //修改是的名字 private String content; // 资料的内容 private boolean changed; //修改后的内容还没存储的话,值为...2009-07-09 14:58:46 · 135 阅读 · 0 评论 -
多线程设计模式 -- suspension
suspension(要等到我准备好噢) 请求对象 [code="java"]public class Request { private final String name; public Request(String name) { this.name = name; } public String getName() { ...2009-07-09 11:19:04 · 109 阅读 · 0 评论 -
多线程设计模式 -- immutable
对象 [code="java"] //类定义为 final public final class Person { //类变量定义为 final private final String name; private final String address; public Person(String name, String add...2009-07-08 15:37:00 · 139 阅读 · 0 评论 -
多线程设计模式--Thread-specific Storage
日志操作类 [code="java"]public class TSLog { private PrintWriter writer = null; // 初始化writer字段 public TSLog(String filename) { try { writer = new PrintWriter(new ...2009-07-22 10:43:05 · 102 阅读 · 0 评论