Skip to content

Commit 34944d5

Browse files
authored
Thread safety support for variable callbacks (#406)
1 parent 87516c8 commit 34944d5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

AndroidSDKCore/src/main/java/com/leanplum/Var.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ private void cacheComputedValues() {
350350
/**
351351
* Updates variable with values from server.
352352
*/
353-
public void update() {
353+
public synchronized void update() {
354354
// TODO: Clean up memory for resource variables.
355355
//data = null;
356356

AndroidSDKCore/src/main/java/com/leanplum/callbacks/VariableCallback.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ public void setVariable(Var<T> variable) {
3636
}
3737

3838
public void run() {
39-
this.handle(variable);
39+
synchronized (variable) {
40+
this.handle(variable);
41+
}
4042
}
4143

4244
public abstract void handle(Var<T> variable);

0 commit comments

Comments
 (0)