2 * Copyright 2011 Huize Dai <geb.1989@gmail.com>
4 * This file is part of MFW.
6 * MFW is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * MFW is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with MFW. If not, see <http://www.gnu.org/licenses/>.
21 import mfw
.pool
.Mission
;
22 import mfw
.timer
.newer
.*;
24 public class Timer_Test
{
25 public static ClockThreadGroup clock
= new ClockThreadGroup(3, true);
26 public static final Object lock
= new Object();
28 public static void main(String
[] args
) throws Throwable
{
29 for (int i
= 1; i
< 10; i
++) {
30 new MissionImpl(i
).start();
40 static class MissionImpl
extends Mission
{
43 public MissionImpl(int id
) {
51 } catch (InterruptedException e
) {
56 for (int i
= 1; i
< 10; i
++) {
57 clock
.add(new TimerEventImpl(id
, i
), 10 * i
);
62 static class TimerEventImpl
extends TimerEvent
{
67 private long previous
= System
.currentTimeMillis();
68 private int[] log
= new int[5];
70 public TimerEventImpl(int id
, int num
) {
75 public boolean isContinue() {
77 System
.out
.println(now
= System
.currentTimeMillis());
78 log
[time
++] = (int) (now
- previous
);
81 System
.out
.println("-------" + id
+ " " + num
+ " " + time
82 + ":" + log
[0] + "," + log
[1] + "," + log
[2] + ","
83 + log
[3] + "," + log
[4]);