据我所知,为了从数组中删除数组列表,必须使用list.remove();
然而,当我这样做时,我的整个程序都停止了。我已经宣布了一种方法,当元素被删除并且它不起作用时倒数。这是宣言:
public static void longWait(int time) {
scheduler.schedule(new Runnable() { public void run() {
//customers.remove(customerIterator.nextIndex());
customers.remove(customers.indexOf(type));
System.out.println(type + " has left.");
}}, time, TimeUnit.SECONDS);
}
我把它调成了我的程序,现在它不想工作
if(value==0){
type = "Slow Customer";
if(customers.contains(type)){
longWait(15);
}
}
该程序使用scheduledExecutorService随机生成客户每秒。我真正想做的是在x秒后删除一个数组列表元素。任何帮助将不胜感激。
Customers customer = new Customer(type);
List<Customer> newCustomers = new ArrayList<Customer>
if(newCustomers.contains(type)){
longWait(15). //Supposed to wait 15 second then remove the customer but nothing is happening
}