You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
984 B
46 lines
984 B
5 years ago
|
/*
|
||
|
* 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) {
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|