package org.Models;

public class Ordonnanceur extends Thread {

    Runnable runnable;
    long pause;

    public Ordonnanceur(Runnable runnable, long pause) {
        this.runnable = runnable;
        this.pause = pause;
    }

    public void stopOrdonnanceur() {
        interrupt();
    }

    @Override
    public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            try {
                Thread.sleep(pause);
                runnable.run();
            } catch (InterruptedException e) {
                break;
            }
        }
    }
}
