Select Git revision
JSXGraph-block-tech-samples.xml
-
Matti Harjula authoredMatti Harjula authored
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();
}
}