headermask image

header image

Monthly Archives: October 2007

Java Concurrent Blocking Queue

前两天公司培训RTSJ说到了JDK1.5的conccurrent包,
这个包中确实增加了不少实用类。课堂上面说到了
这个精简的阻塞工作队列,感觉很实用

//这个例子示例了使用阻塞队列协调生产者和消费者的关系,当有一些工作需要做的时候,生产者向队列中增加工作单元。消费者多
//线程消费。重点在于当队列满的时候生产者向队列中增加这个动作阻塞。

// Create a bounded blocking queue of integers
final int capacity = 10;
BlockingQueue queue = new ArrayBlockingQueue(capacity);
// Create a set of worker threads
final int numWorkers = 2;
Worker[] workers = new Worker[numWorkers];
for (int i=0; i workers[i] = new Worker(queue);
workers[i].start();
}try {
// Add some work to the queue; block if the queue is full.
// Note that null cannot be […]

热烈庆祝博客重新开张。。:)

算来两年没写博客了。。太不像话了。
看我女朋友没事总能写写。。看的心里痒痒也想写了。。她也说我也该写写了。。是了
今天花了一下午的时间弄了这个,theme挺满意。sidebar可以随意调整,感觉不错不错的。。
长时间来也积累一些思考。。慢慢道来吧
原来在新浪的老博客记忆还是比较深刻的。光数据就倒腾了俩小时。
现在都弄好了。。很有收获感。