Sync to avoid concurrent access issues
This commit is contained in:
parent
5cb541b5e4
commit
79d4d7bfcf
1 changed files with 19 additions and 15 deletions
|
@ -1028,6 +1028,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
|
||||
public void key(int code, boolean down, int pointerID) {
|
||||
if (code < MAX_TOUCHES) {
|
||||
synchronized(queuedCodes) {
|
||||
if (down) {
|
||||
Integer cI = code + 1;
|
||||
queuedCodes.add(cI);
|
||||
|
@ -1039,11 +1040,13 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
queuedCodes.add(cI);
|
||||
touches[code] = 0;
|
||||
}
|
||||
}
|
||||
x48.flipScreen();
|
||||
}
|
||||
}
|
||||
|
||||
public int waitEvent() {
|
||||
synchronized(queuedCodes) {
|
||||
if (queuedCodes.size() == 0) {
|
||||
return 0;
|
||||
} else {
|
||||
|
@ -1051,6 +1054,7 @@ public class HPView extends SurfaceView implements SurfaceHolder.Callback, Runna
|
|||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected int width;
|
||||
protected int height;
|
||||
|
|
Loading…
Reference in a new issue