Skip to content
This repository was archived by the owner on Jul 14, 2021. It is now read-only.

Commit 2f8f64b

Browse files
committed
make it thread safe
1 parent 77b7a95 commit 2f8f64b

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

virtualview/src/main/java/com/tmall/wireless/vaf/virtualview/ViewFactory.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -464,23 +464,23 @@ private TmplWorker() {
464464
isRunning = false;
465465
}
466466

467-
public void setViewFactory(ViewFactory viewFactory) {
467+
public synchronized void setViewFactory(ViewFactory viewFactory) {
468468
mViewFactory = new WeakReference<>(viewFactory);
469469
}
470470

471-
public boolean isRunning() {
471+
public synchronized boolean isRunning() {
472472
return isRunning;
473473
}
474474

475-
public void offerTask(TmplTask task) {
475+
public synchronized void offerTask(TmplTask task) {
476476
try {
477477
mLoadingPool.put(task);
478478
} catch (InterruptedException e) {
479479
e.printStackTrace();
480480
}
481481
}
482482

483-
public void executeTask(String type) {
483+
public synchronized void executeTask(String type) {
484484
if (TextUtils.isEmpty(type)) {
485485
return;
486486
}
@@ -505,7 +505,7 @@ public synchronized void start() {
505505
isRunning = true;
506506
}
507507

508-
public void stopSelf() {
508+
public synchronized void stopSelf() {
509509
isRunning = false;
510510
interrupt();
511511
}

0 commit comments

Comments
 (0)