package org.Models;

public class Ordonnanceur extends Thread {

    Runnable runnable;
    long pause;
    private boolean estActif = true;

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

    public void stopOrdonnanceur() {
        estActif = false;
        interrupt();
    }

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