Best Answer - Chosen by Voters
This sounds like a question about data structures. And a fun project :)
I think the most straightforward way would to have a single thread "generating" the cars. For each pump, you can store a java.util.Queue<Car> to keep track of them. You can either have a seperate thread for each pump or have a scheduler thread of some sort (maybe the same one as generating the cars). This way you can "enqueue" the cars from the producer thread and "dequeue" them in the consumer thread(s).
Sample for creation:
Thread creator = new Thread(new Runnable(){
public void run(){
while(programRunning){
Car car = createRandomCar();
Pump pump = choosePump();
car.goto(pump); //car implementation enqueues itself here in the pump
Thread.currentThread().sleep(Math.rand… 20000));
}
}
});
creator.start();
//continue in program