Summary: Add models for `View` methods that schedule on the UI thread. Reviewed By: skcho Differential Revision: D21767954 fbshipit-source-id: 015441ea7master
parent
7e902f241d
commit
bad9ab08e7
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
class MyView extends View {
|
||||
MyView(Context c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
Object monitorA, monitorB;
|
||||
@ForNonUiThread private final Executor mNonUiThreadExecutor = null;
|
||||
|
||||
void scheduleOnBGThread() {
|
||||
mNonUiThreadExecutor.execute(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (monitorA) {
|
||||
synchronized (monitorB) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void scheduleOnUIThread() {
|
||||
post(
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
synchronized (monitorB) {
|
||||
synchronized (monitorA) {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in new issue