1
10 threads are agreed when the Client connects to the server, when the Client asks for a word, The server wakes up these threads and they will go through a list of tasks.
What I wanted to happen: whenever a thread scans that word, it removes that task from the list so that when the next one runs this task it is no longer in the list.
What happens: more than one thread starts to scan(), and they all scan() the first task.
public  class ThreadSearcher extends Thread{
    private int x;
    public ThreadSearcher(int x){
        this.x=x;   
    }
    @Override
    public void run(){
        while(!interrupted()){
            System.out.println("Comecei a correr:" + x); 
            try {
                Tarefa t = getTarefas().get(0);
                scan(t);
                System.out.println("Sou a "+ this.x + " e fiz o scan de " + t.getStart() + "a" + t.getFinish());
                System.out.println("Sou a " + x + "antes de remover tinha " + tarefas.size());
                tarefas.remove(t);
                System.out.println("Sou a " + x + "depois de remover tinha " + tarefas.size());
                System.out.println("removi a" + t);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    }
}
Enter the code of your class
Tarefaand the class where you create yourThreadSearcher, please.– Felipe Marinho