- 浏览: 122684 次
- 性别:
- 来自: 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 1006/** * A standard implementati ... -
Count Down Latch example code
2009-04-22 10:38 1110Key point : 1) 1 task is co ... -
3 ways to break dead lock
2009-04-21 17:30 7131) supply special resources. ... -
Blocking Queue Usage
2009-04-20 11:21 8053 implementations: LinkedBlocki ... -
The usage of Lock and Condition
2009-04-18 12:31 1047//: concurrency/waxomatic2/WaxO ... -
Re entrantLock usage
2009-04-15 17:15 1294a thread can be really interru ... -
new interrupt in java5
2009-04-15 12:08 637In Java 5, Thread.interrupt() i ... -
interrupt
2009-04-15 10:57 7741) Each thread has a boolean in ... -
Executor Service Usage
2009-04-14 18:18 872ExecutorService exec = Executor ... -
Thread Local usage
2009-04-14 17:46 766ThreadLocal usage – from Javado ... -
Timer TimerTask usage
2009-04-14 12:03 694Timer typical usage new Tim ... -
wait, notify及线程通讯机制
2009-02-26 22:42 8171) wait(), notify() 方法被调用的时候,只要 ... -
Java Thread programming basical knowledge
2009-02-26 22:40 1038yield() : Give a hint to the th ... -
Count Down Latch explanation
2008-10-02 10:29 907Very important paragraph on how ... -
Scheduled Executor Service
2008-07-22 11:27 1071Executor can return Executor, E ... -
Executor usage
2008-07-22 11:04 854Executor is used to arrange thr ... -
Callable Usage
2008-07-22 10:24 893The important thing need to loo ...
相关推荐
SIP API for Java 2 Micro Edition Javadoc
javadoc插件使用文档 javadoc是Sun公司提供的一个技术,它从程序源代码中抽取类、方法、成员等注释形成一个和源代码配套的API帮助文档。javadoc工具能够从下列对象中提取出消息:包、公共类、公共接口、公共可能受...
idea easy_javadoc插件
Eclipse 与 Javadoc 配置解决方案 Eclipse 是一个功能强大且流行的集成开发环境(IDE),而 Javadoc 是 Java 官方提供的 API 文档生成工具。然而,在 Eclipse 中配置 Javadoc 并不是一件容易的事情。本文将详细介绍...
redis-service 的JavaDoc
javadoc 注释规范 javadoc 是 Java 语言中的一种文档注释工具,用于生成 HTML 格式的文档。根据给定的文件信息,我们可以总结出以下知识点: 一、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