Fix CB-135 Multithreaded access on CallbackServer javascript object.

This commit is contained in:
Bryce Curtis 2012-01-06 22:23:49 -06:00
parent bc309c9f00
commit 8db5e06c62

View File

@ -314,10 +314,11 @@ public class CallbackServer implements Runnable {
* @return int
*/
public int getSize() {
synchronized(this) {
int size = this.javascript.size();
//System.out.println("getSize() = " + size);
return size;
}
}
/**
* Get the next JavaScript statement and remove from list.
@ -325,18 +326,17 @@ public class CallbackServer implements Runnable {
* @return String
*/
public String getJavascript() {
synchronized(this) {
if (this.javascript.size() == 0) {
return null;
}
String statement = this.javascript.remove(0);
//System.out.println("CallbackServer.getJavascript() = " + statement);
if (this.javascript.size() == 0) {
synchronized (this) {
this.empty = true;
}
}
return statement;
}
}
/**
* Add a JavaScript statement to the list.
@ -344,9 +344,8 @@ public class CallbackServer implements Runnable {
* @param statement
*/
public void sendJavascript(String statement) {
//System.out.println("CallbackServer.sendJavascript("+statement+")");
this.javascript.add(statement);
synchronized (this) {
this.javascript.add(statement);
this.empty = false;
this.notify();
}