Commit 1e278067 authored by Xiaoying Pu's avatar Xiaoying Pu

the timer and the loop are blocking each other

parent 3f901584
......@@ -52,22 +52,26 @@ public class Trial extends Thread {
@Override
public void run() {
while (true) {
ProtoAction ac = actionQueue.poll();
if (ac != null) {
if (ac.getType() == ActionType.QUIT_TRIAL) {
return;
Runnable task = () -> {
while (true) {
ProtoAction ac = actionQueue.poll();
if (ac != null) {
if (ac.getType() == ActionType.QUIT_TRIAL) {
ac.run();
return;
}
System.out.println("-------------------An action says that it's runnning");
System.out.println(ac.getType());
ac.run();
}
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(Trial.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("-----------------------------I am running");
System.out.println(ac.getType());
ac.run();
}
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(Trial.class.getName()).log(Level.SEVERE, null, ex);
}
}
};
new Thread(task).start();
}
/**
......@@ -132,7 +136,7 @@ public class Trial extends Thread {
@Override
public void run() {
System.out.println("SLEEP starts at -------->" + System.currentTimeMillis()/1000L);
System.out.println("SLEEP starts at -------->" + System.currentTimeMillis() / 1000L);
int tDecisions = Configurator.gettDecisions();
try {
Thread.sleep(tDecisions);
......@@ -141,10 +145,9 @@ public class Trial extends Thread {
}
pFacade.endDecision();
System.out.println("SLEEP ends at -------->" + System.currentTimeMillis()/1000L);
System.out.println("SLEEP ends at -------->" + System.currentTimeMillis() / 1000L);
// own goal
theListener.run(EventType.DECISION_FINISHED);
}
......@@ -168,8 +171,8 @@ public class Trial extends Thread {
actionQueue.add(new QuitAction(ActionType.QUIT_TRIAL));
return;
}
System.out.println("====================AT Trial " + iterations.get()+"======================");
System.out.println("====================AT Trial " + iterations.get() + "======================");
// how ugly is this
if (type == ActionType.START_HWL_DIGIT
|| type == ActionType.START_LWL_DIGIT) {
......@@ -185,8 +188,9 @@ public class Trial extends Thread {
// start UDP to MouseTracker
// go look at the mousetracker!!!
// TODO why is this not sleeping/???/
System.out.println("WHY ARE YOU NOT SLEEPING");
actionQueue.add(new SleepForDecisions(ActionType.SLEEP_FOR_DECISIONS));
pFacade.startAndWait(curState);
//pFacade.startAndWait(curState);
}
int tTask = Configurator.gettSTask();
......@@ -195,11 +199,11 @@ public class Trial extends Thread {
} catch (InterruptedException ex) {
Logger.getLogger(Dm_task.class.getName()).log(Level.SEVERE, null, ex);
}
// immediately after
// immediately after
sFacade.endDigitShowing();
System.out.println("Digit should go away now");
// yooo end digit showing
}
}
}
......@@ -9,7 +9,7 @@ tSTask = 1000
tPause = 4000
tDecisions = 30000
tDecisions = 5000
nTrials = 3
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment