2
我正在开发一个队列模拟,使用摆动计时器在一段时间后退出对象。间隔取决于队列中的下一个对象,从中获取一个整数,并设置相应定时器的延迟。在运行期间修改摆轮定时器的延迟
下面是该程序的相关代码段(注:_SECONDS_PER_ITEM
是在其他地方规定2000
常数):
// stop the timer
qTimer[q].stop();
// peek at how many items the customer has, and set the delay.
qTimer[q].setDelay(customerQueue[q].peek().getItems()*_SECONDS_PER_ITEM);
// the next time around, this method will see the flag, and dequeue the customer.
working[q] = true;
// denote that the customer is active on the UI.
lblCustomer[q][0].setBorder(new LineBorder(Color.RED, 2));
// start the timer.
qTimer[q].start();
我的问题是,每一个客户,无论多少他们的项目,被处理在一秒钟内。
是否有其他方法或技术我应该用来设置延迟?