📄 countworker.java
字号:
/*
* Created on 2005-3-29
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package cn.edu.hust.cgcl.biogrid.dispatcher;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Timer;
import java.util.TimerTask;
import java.util.Vector;
/**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class CountWorker {
private final Timer timer = new Timer(true);
private final int minutes;
private Vector workerNodeList;
private int c=0;
private Integer in;
private boolean computeFlag=true;
public static int workerCount[];
//public static int workerCountTemp[];
private LinkedList ll;
public CountWorker(int minutes,Vector workerNodeList) {
workerCount=new int[60];
for(int j=0;j<60;j++)
workerCount[j]=0;
//workerCountTemp=new int[60];
ll=new LinkedList();
this.minutes = minutes;
this.workerNodeList=workerNodeList;
}
public void start() {
timer.schedule(new TimerTask() {
public void run() {
count();
//timer.cancel();
}
private void count() {
// Start a new thread to count...
in=new Integer(workerNodeList.size());
ll.add(in);
if(computeFlag)
{
for(int j=59-c;j<59;j++)
workerCount[j]=workerCount[j+1];
workerCount[59]=workerNodeList.size();
if(++c>=60)
computeFlag=false;
}
else
{
c=0;
//workerCount[c++]=workerNodeList.size();
ListIterator iter=ll.listIterator();
iter.next();
iter.remove();
while(iter.hasNext())
{
workerCount[c++]=((Integer)(iter.next())).intValue();
}
}
}
}, minutes *1000, minutes *60 *1000);
}
public void quit()
{
timer.cancel();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -