package money.thread;

import money.Log;

public class AddRunner extends ExecutableRunner {

    private static final String TAG = "AddRunner";
public int a; public AddRunner(Object readyTaskListLock, String description, int exclusiveValue, int type) {
super(readyTaskListLock, description, exclusiveValue, type);
a = 0;
} @Override
public void run() { while (true) {
a++;
Log.d(TAG, "description:" + description + " a:" + a); try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
} if (a == 5) {
synchronized (readyTaskListLock) {
// TODO: modify state
readyTaskListLock.notify();
}
return;
}
}
}
}
package money;

import money.thread.AddRunner;
import money.thread.ExecutableRunner; public class Test { private static final String TAG = "Test"; public static void main(String[] args) {
Processor processor = Processor.instance();
processor.start(); // wait for the initialization of processor
try {
Thread.sleep(300);
} catch (InterruptedException e) {
e.printStackTrace();
} for (int i = 0; i < 4; i++) {
ExecutableRunner runner = new AddRunner(processor.getReadyTaskListLock(), "" + i, 0, 0);
processor.addTask(runner); try {
Thread.sleep(2000);
} catch (InterruptedException e) {
e.printStackTrace();
}
} Log.d(TAG, "to add other task....");
}
}

随机推荐

  1. 选择快速源来加速linux系统更新

    sudo pacman-mirrors -c China -g 引用自manjaro百度贴吧

  2. [BZOJ 1150] 数据备份

    Link:https://www.lydsy.com/JudgeOnline/problem.php?id=1150 Solution: 思路和洛谷P1484完全相同 只不过将求最大不相邻的点权改为最 ...

  3. React Native 让组件做到局部刷新

    利用RN的状态机机制,我们可以通过this.setState({optional:...})来控制界面的刷新,但是一定会触发render方法,那如何保证不调用render方法从而做到界面的局部刷新呢? ...

  4. debian6 安装VirtualBox的方法

    方法一: 参考: https://www.virtualbox.org/wiki/Linux_Downloads    更新sources.list deb http://download.virtu ...

  5. nativeexcel数据集导出excel

    nativeexcel数据集导出excel uses Dataset2Excel; procedure Tfdm.exportXLS(dataset: TDataSet);var xls: TData ...

  6. 【spring data jpa】jpa中使用in查询或删除 在@Query中怎么写 ,报错:org.springframework.expression.spel.SpelEvaluationException: EL1007E: Property or field 'goodsConfigUid' cannot be found on null 怎么处理

    示例代码如下: @Modifying @Transactional @Query("delete from GoodsBindConfigMapping gbc " + " ...

  7. 使用Ant项目打包

    一.前沿 前段时间公司为了做一个新闻发布系统,就使用了开源的JEECMS系统,(非人类啊,泪~~~),项目不是maven构建的,项目的打包部署非常的麻烦,没办法只能使用Ant,Ant是比较古老的打包部 ...

  8. javascript:判断支持哪种监听

    if (typeof window.addEventListener != "undefined") { window.addEventListener("load&qu ...

  9. Bootstrap幻灯片

    Bootstrap幻灯片的制作利用到了Carousel插件,包含:左右箭头.图片.点点导航 <div id="carousel-example-generic" class= ...

  10. Session集中式管理

          Asp.net Session集中式管理主要有StateServer(状态服务器).Sqlserver(数据库服务器).自定义(如Redis缓存服务器)等,本文主要介绍StateServe ...