Skip to content
Snippets Groups Projects
Select Git revision
  • fix-remote-urls
  • master default
  • fix-remote-url_v4.9.1
  • fix-remote-url_v4.8.3
  • fix-remote-url_v4.8.x
  • fix-remote-url_v4.7.x
  • fix-remote-url_v4.6.0
7 results

JSXGraph-block-tech-samples.xml

  • WorkingExplorers.java 949 B
    package algorithm;
    
    import parallel.EagerWorkingThread;
    import parallel.SharedRessources;
    
    import java.util.ArrayList;
    import java.util.PriorityQueue;
    import java.util.Queue;
    import java.util.Stack;
    import java.util.concurrent.LinkedBlockingQueue;
    
    public class WorkingExplorers extends EagerWorkingThread {
    
        public WorkingExplorers() {
            super();
            this.setAllowRunning(true);
    
            System.out.println("[*] Thread initialized @" + this.getName());
    
        }
    
        private Stack<Explorer> currentWaitingExplorers = new Stack<>();
    
        @Override
        public void onBegin() {
        }
    
        @Override
        public void onTrigger() {
            if (!currentWaitingExplorers.isEmpty())
                currentWaitingExplorers.pop().explore();
        }
    
        @Override
        public void onEnd() {
        }
    
        public void add(Explorer explorer) throws InterruptedException {
            this.currentWaitingExplorers.push(explorer);
            this.trigger();
        }
    
    }