v0.6.0a: further improvements/fixes to threading logic

This commit is contained in:
Evan Debenham 2017-06-08 15:25:59 -04:00
parent 0697268a73
commit db97210728
2 changed files with 17 additions and 15 deletions

View File

@ -179,8 +179,10 @@ public abstract class Actor implements Bundlable {
boolean interrupted = false;
do {
now = Float.MAX_VALUE;
current = null;
if (!interrupted) {
now = Float.MAX_VALUE;
for (Actor actor : all) {
@ -192,8 +194,9 @@ public abstract class Actor implements Bundlable {
}
}
}
if (!interrupted && current != null) {
if (current != null) {
Actor acting = current;
@ -228,6 +231,7 @@ public abstract class Actor implements Bundlable {
synchronized (Thread.currentThread()) {
synchronized (GameScene.class){
//signals to the gamescene that actor processing is finished for now
GameScene.class.notify();
}
try {

View File

@ -416,11 +416,10 @@ public class GameScene extends PixelScene {
//tell the actor thread to finish, then wait for it to complete any actions it may be doing.
if (actorThread.isAlive()){
synchronized (GameScene.class){
synchronized (actorThread) {
actorThread.interrupt();
}
synchronized (GameScene.class){
if (actorThread.getState() != Thread.State.WAITING) {
try {
GameScene.class.wait(5000);
} catch (InterruptedException e) {
@ -435,7 +434,6 @@ public class GameScene extends PixelScene {
}
}
}
}
freezeEmitters = false;