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. POJ 3180 The Cow Prom(SCC)

    [题目链接] http://poj.org/problem?id=3180 [题目大意] N头牛,M条有向绳子,能组成几个歌舞团?要求顺时针逆时针都能带动舞团内所有牛. [题解] 等价于求点数大于1的 ...

  2. 【博弈论】【SG函数】【枚举】bzoj1874 [BeiJing2009 WinterCamp]取石子游戏

    枚举第一步可能达到的状态,判断是否是必败态即可. #include<cstdio> #include<set> #include<cstring> using na ...

  3. Scala实战高手****第5课:零基础实战Scala函数式编程及Spark源码解析

    Scala函数式编程 ----------------------------------------------------------------------------------------- ...

  4. NSNotificationCenter监听TextField文字变化

    注册 1: NSNotificationCenter.defaultCenter().addObserver(self, selector: "textDidChange", na ...

  5. 表或视图不存在 Hibernate Oracle

    曾经运行一个别人写的程序,之前连的别人的机器的数据,后来我把数据导入到本地数据库中运行,出错,如下:Hibernate: select sum(rdb_alert_0_.EVENT_COUNT) as ...

  6. C#正则表达式开源工具

    先交代一下背景,最近工作中经常用到正则表达式,而正则表达式这个东西我个人觉得很鸡肋,不用吧,有些功能实现起来会很麻烦.用吧,又不是说工作中经常用到,只是有时候有些需要求用到而已.但是正则表达式只要一段 ...

  7. SQL SERVER 常用命令

    红色为常用 0.row_number() over 和数据组合sale/cnt select *,row_number() over(order by productname) as rownumbe ...

  8. SqlServer_删除重复行只保留一条记录

      前提:相同的数据重复往数据库写入,导致存在仅主键Id不同的重复数据,现在需要去除重复数据,仅保留重复数据中Id最大的一条   思路: 1.找出存在重复数据的记录,并取重复数据中最大的Id值 2.删 ...

  9. 一起來玩鳥 Starling Framework(9)Particle

    最後,來看看Starling裡一個很炫的功能:Particle.Particle屬於extension,所以要另外下載檔案:Starling-Extension-Particle-System.下載之 ...

  10. Solr6 Suggest(智能提示)

    1.介绍 Solr从1.4开始便提供了检查建议,检索建议目前是各大搜索的标配应用,主要作用是避免用户输入错误的搜索词,同时将用户引导到相应的关键词搜索上.通常,我们将其称为搜索联想. 其效果如图所示. ...