Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

262
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda