Thread!!
public class Sincronizzazione implements Runnable {
private Prova miaProva;
static int tMin = 3000;
static int tMax = 6000;
//Identificato auto
int idAuto;
public Sincronizzazione(int idAuto,Prova Variabile){
System.out.println("Sono vivo auto: "+idAuto);
miaProva=Variabile;
this.idAuto = idAuto;
}
@Override
public void run() {
try {
miaProva.entraNelParcheggio();
} catch (InterruptedException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
int tRandom = (int) Math.floor(Math.random() * tMax) + tMin;
System.out.println("Sono entrato auto: "+idAuto+" per tempo: "+tRandom);
try {
Thread.sleep(tRandom);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
miaProva.esconoDalPacheggio(idAuto);
}
}
Quello che vorrei fare, come hai detto tu, le macchina devono rispettare l'ordine d'ingresso.
Pero' mi piacerebbe usare un arraylist.
Quando hai tempo mi potresti inviare un esempio di codice
Grazie mille