Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

255
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda