/*
 * Automechaniker.java, Created on 18.01.2005
 * 
 */
// package de.unidue.is.prog.verkehr;

/**
 * @author kriewel
 *
 */
public class Automechaniker extends Thread {

    Warteschlange schlange;
    String name;
    
    /**
     * 
     */
    public Automechaniker(Warteschlange s, String n) {
        schlange = s;
        name = n;
        System.out.println(n + " wurde eingestellt.");
    }

    public void run() {
        while (true) {
            Auto auto = null;
            
            synchronized (schlange) {
                auto = schlange.autoRaus();
            }
            
            if (auto == null) {
                try {
                    Thread.sleep(1000);                   
                } catch (InterruptedException e) {
                    break;
                }
            } else {
                try {
                    Thread.sleep((int)(1000*Math.random()));                   
                } catch (InterruptedException e) {
                    break;
                }
                System.out.print(name + " : ");
                auto.reparieren();
            }
            
        }
    }
    
    public static void main(String[] args) {
    }
}
