Skip to content
Snippets Groups Projects
Select Git revision
  • c695e6fc5f353561ba424bee031ffc4ac22cd51c
  • main default protected
  • correction_video
  • going_further
  • ImprovedMouseInteraction
  • final2023
  • template
  • ModifGUI
8 results

CellularAutomatonSimulation.class.uniqueId2

Blame
  • Forked from YAGOUBI Rim / Game of life Template
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    Ticker.java 802 B
    package fr.univamu.ticker;
    
    import fr.univamu.ticker.TickListener;
    
    import java.util.ArrayList;
    import java.util.List;
    
    public class Ticker {
    
        private Thread ticking;
        private final List<TickListener> listeners = new ArrayList<>();
    
        public void add(TickListener listener) {
            listeners.add(listener);
        }
    
        public void startTicking() {
            ticking = new Thread(() -> {
                try {
                    while (true) {
                        Thread.sleep(1000);
                        listeners.forEach(TickListener::notifyTick);
                    }
                } catch (InterruptedException exc) {
                    // Done
                }
            });
            ticking.setDaemon(false);
            ticking.start();
        }
    
    
        public void stopTicking() {
            ticking.interrupt();
        }
    }