- 浏览: 121398 次
- 性别:
- 来自: Singapore
文章分类
- 全部博客 (112)
- Tiger Thread (18)
- Perforce (6)
- Spring (5)
- maven (3)
- log4j (3)
- Quartz Scheduler (4)
- unix and linux (12)
- hibernate (3)
- Enum (1)
- Futures and Options (1)
- Market Making (2)
- Java Basic (11)
- Tibco EMS (3)
- F I X message (5)
- equity derivative (2)
- Sybase (3)
- XML (1)
- JUnit (2)
- J A X B 2.0 (1)
- N I O (1)
- windows batch file (1)
- Cruise Control (1)
- util Class (5)
- ant (1)
- JMS (1)
- profiling (0)
- Sql Server (6)
- GXT (2)
- eclipse (1)
- Generics (1)
- Tibco RV (3)
- Autosys (0)
- Message (1)
最新评论
-
houzhe11:
<property name="proxyTa ...
AOP usage -- BeanNameAutoProxyCreator usage
A synchronization aid that allows a set of threads to all wait for each other to reach a common barrier point. CyclicBarriers are useful in programs involving a fixed sized party of threads that must occasionally wait for each other. The barrier is called cyclic because it can be re-used after the waiting threads are released.
A CyclicBarrier supports an optional Runnable
command that is run once per barrier point, after the last thread in the party arrives, but before any threads are released. This barrier action is useful for updating shared-state before any of the parties continue.
Sample usage: Here is an example of using a barrier in a parallel decomposition design:
class Solver { final int N; final float[][] data; final CyclicBarrier barrier; class Worker implements Runnable { int myRow; Worker(int row) { myRow = row; } public void run() { while (!done()) { processRow(myRow); try { barrier.await(); } catch (InterruptedException ex) { return; } catch (BrokenBarrierException ex) { return; } } } } public Solver(float[][] matrix) { data = matrix; N = matrix.length; barrier = new CyclicBarrier(N, new Runnable() { public void run() { mergeRows(...); } }); for (int i = 0; i < N; ++i) new Thread(new Worker(i)).start(); waitUntilDone(); } }
Here, each worker thread processes a row of the matrix then waits at the barrier until all rows have been processed. When all rows are processed the supplied Runnable
barrier action is executed and merges the rows. If the merger determines that a solution has been found then done() will return true and each worker will terminate.
If the barrier action does not rely on the parties being suspended when it is executed, then any of the threads in the party could execute that action when it is released. To facilitate this, each invocation of await
returns the arrival index of that thread at the barrier. You can then choose which thread should execute the barrier action, for example:
if (barrier.await() == 0) { // log the completion of this iteration }
The CyclicBarrier uses a fast-fail all-or-none breakage model for failed synchronization attempts: If a thread leaves a barrier point prematurely because of interruption, failure, or timeout, all other threads, even those that have not yet resumed from a previous await
, will also leave abnormally via BrokenBarrierException
(or InterruptedException if they too were interrupted at about the same time).
发表评论
-
Delayed interface and Delay Queue
2009-04-22 17:42 1000/** * A standard implementati ... -
Count Down Latch example code
2009-04-22 10:38 1089Key point : 1) 1 task is co ... -
3 ways to break dead lock
2009-04-21 17:30 7031) supply special resources. ... -
Blocking Queue Usage
2009-04-20 11:21 7943 implementations: LinkedBlocki ... -
The usage of Lock and Condition
2009-04-18 12:31 1038//: concurrency/waxomatic2/WaxO ... -
Re entrantLock usage
2009-04-15 17:15 1289a thread can be really interru ... -
new interrupt in java5
2009-04-15 12:08 634In Java 5, Thread.interrupt() i ... -
interrupt
2009-04-15 10:57 7631) Each thread has a boolean in ... -
Executor Service Usage
2009-04-14 18:18 861ExecutorService exec = Executor ... -
Thread Local usage
2009-04-14 17:46 760ThreadLocal usage – from Javado ... -
Timer TimerTask usage
2009-04-14 12:03 688Timer typical usage new Tim ... -
wait, notify及线程通讯机制
2009-02-26 22:42 8031) wait(), notify() 方法被调用的时候,只要 ... -
Java Thread programming basical knowledge
2009-02-26 22:40 925yield() : Give a hint to the th ... -
Count Down Latch explanation
2008-10-02 10:29 896Very important paragraph on how ... -
Scheduled Executor Service
2008-07-22 11:27 1060Executor can return Executor, E ... -
Executor usage
2008-07-22 11:04 842Executor is used to arrange thr ... -
Callable Usage
2008-07-22 10:24 884The important thing need to loo ...
相关推荐
SIP API for Java 2 Micro Edition Javadoc
idea easy_javadoc插件
redis-service 的JavaDoc
javadoc插件使用文档
JMS API JAVADOC,详细解释方法的使用。
Myeclipse导出Javadoc步骤
4)Javadoc:javadoc1.8谷歌翻译(目前能找到的最好的翻译版本) 二、操作步骤: 1、点开项文件夹找到rt.jar。 2、右键点击属性选择javadoc位置。 3、选java类中的关键字按F1就可以看到中文帮助。 4、本文插件已含全部...
这一段时间在研究Javadoc的问题,前面发布的Javadoc转换chm帮助文档的四种方法总结,总结了如何实现Javadoc到chm的转换,希望给大家带来了一些方便,今天我们来说说如何利用Eclipse生成个性化的Javadoc 文档,也希望...
JavaDoc写法规范 JavaDoc写法规范 JavaDoc写法规范
Eclipse中自动生成Javadoc的方法,以及一些标签的含义
Eclipse中设置javadoc中文帮助文档的方法 适合初学者
中文JAVADOC中文JAVADOC
注释规范(javadoc)
非常标准的javadoc注释文档,值得试用
1、Javadoc2chm工具
rabbitmq-javadoc rabbitmq-javadoc html
hadoop 2.4.1 JAVADOC
javadoc利用Java编译程序javac对程序代码源文件中的声明和文档注释进行语法分析,并在默认情况下...这样当涉及类和内部类的有关描述时,是否正确地设置了classpath变量可能会影响到javadoc命令是否可以完全成功执行。
javadocjavadoc