解决方案 »
- 找本设计模式的书!
- java数据包定议,这样写对不????
- 关于外部类属性访问、键盘事件、文本实时更新的问题
- JDK的一个bug?如何解决!(关于Ctrl+x响应)
- 请教下怎么把javax/servlet文件夹里的*.class和javax/servlet/http里的*.class打包到一个jar文件里去啊
- 请推荐在windows 2000下使用组件:外观象windows XP一样。
- 请问有什么方法模拟鼠标点击事件
- 找不到文件:FileNotFoundException
- 帮我解决这个问题给80~~~~~~~~`至少
- 怎样用Java执行win环境下的EXE程序,并且接管EXE程序的输出和输入
- NavigableSet怎用用,为什么总找不到符号?
- 嵌套类与子类命名相同产生的问题
Broker broker = new Broker(); int consumerCount = 10;
ExecutorService threadPool = Executors
.newFixedThreadPool(consumerCount + 1); for (int i = 0; i < consumerCount; ++i) {
DatabaseFactory.getInstance().saveAliasAs("consumer" + i);
threadPool.execute(new Consumer("consumer" + i, broker));
} Future producerStatus = threadPool.submit(new Producer(broker)); // this will wait for the producer to finish its execution.
producerStatus.get(); threadPool.shutdown();
threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.NANOSECONDS);
} catch (Exception e) {
StackUtility.logStackTrace(log, e);
}
public ArrayBlockingQueue<FileWrapper> queue = new ArrayBlockingQueue<FileWrapper>(
4000);
public Boolean continueProducing = Boolean.TRUE; public void put(FileWrapper data) throws InterruptedException {
this.queue.put(data);
} public FileWrapper get() throws InterruptedException {
// return this.queue.take();
return this.queue.poll(3, TimeUnit.SECONDS);
}
}