Mercurial > hg > Members > sugi > javafx
changeset 33:f5cf57c645ab
bug fixed about notify but not perfect
author | sugi |
---|---|
date | Mon, 11 Nov 2013 17:13:41 +0900 |
parents | e580cd6b225a |
children | 4ddef9b2e1aa |
files | src/alice/topology/manager/keeparive/PingScheduler.java |
diffstat | 1 files changed, 10 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/topology/manager/keeparive/PingScheduler.java Mon Nov 11 16:25:55 2013 +0900 +++ b/src/alice/topology/manager/keeparive/PingScheduler.java Mon Nov 11 17:13:41 2013 +0900 @@ -13,12 +13,12 @@ public boolean updateFlag = false; private boolean postponeFlag = false; - private boolean nowTaskFlag = false; public long time = 0; public int taskNum = 0; public TaskInfo nowTask; private long totalTime = 0; + private long postponeTime = 0; public long getTotalTime(){ return totalTime; @@ -29,11 +29,14 @@ } public synchronized void postpone(String name){ - long postponeTime = nowTask.getTime() - (System.currentTimeMillis() - time); + long elapsedTime = System.currentTimeMillis() - time; + totalTime += elapsedTime; + postponeTime = nowTask.getTime() - elapsedTime; if (name.equals(nowTask.getName())){ TaskInfo nextTask = list.get(0); nextTask.setTime(postponeTime + nextTask.getTime()); - nowTaskFlag = true; + nowTask.setTime(INTERVAL); + addTask(nowTask); } else { for (int cnt = 0 ;cnt < list.size(); cnt++){ TaskInfo task = list.get(cnt); @@ -45,11 +48,11 @@ list.remove(cnt); task.setTime(INTERVAL); addTask(task); + postponeFlag = true; break; } } } - postponeFlag = true; notify(); } @@ -99,16 +102,9 @@ if (nowTask.getTime()!=0) this.wait(nowTask.getTime()); if (postponeFlag){ - long remainingTime = nowTask.getTime() - (System.currentTimeMillis() - time); - totalTime += (System.currentTimeMillis() - time); - if (nowTaskFlag){ - nowTask.setTime(INTERVAL); - addTask(nowTask); - } else { - nowTask.setTime(remainingTime); - list.add(0, nowTask); - updateFlag = true; - } + nowTask.setTime(postponeTime); + list.add(0, nowTask); + updateFlag = true; postponeFlag = false; } else { totalTime +=nowTask.getTime();