Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

259
Views
How to remove an array list element using a timer?

I understand that in order to remove an array list from an array, you must use list.remove();

Yet, when I do that, my entire program stops. I've declared a method to count down when the element is supposed to be removed and it's not working. Here's the declaration:

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);

}

I called it into my program, and now it doesn't want to work

if(value==0){
        type = "Slow Customer";
        if(customers.contains(type)){   
            longWait(15);
        }

    }

The program randomly generates customers every amount of seconds using scheduledExecutorService. What I'm really trying to do is remove an array list element after x amount of seconds. Any help would be appreciated.

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 
}
over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!