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.
57 lines
1.1 KiB
57 lines
1.1 KiB
6 years ago
|
/*
|
||
|
* Copyright (c) 2018-present, Facebook, Inc.
|
||
|
*
|
||
|
* This source code is licensed under the MIT license found in the
|
||
|
* LICENSE file in the root directory of this source tree.
|
||
|
*/
|
||
|
|
||
|
import android.support.annotation.UiThread;
|
||
|
|
||
|
class ObjWait {
|
||
|
Object z;
|
||
|
|
||
|
void waitOnAnyWithoutTimeoutOk() throws InterruptedException {
|
||
|
synchronized(z) {
|
||
|
z.wait();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Object o;
|
||
|
|
||
|
@UiThread
|
||
|
void waitOnMainWithoutTimeoutBad() throws InterruptedException {
|
||
|
synchronized(o) {
|
||
|
o.wait();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@UiThread
|
||
|
void waitOnMainWithExcessiveTimeout1Bad() throws InterruptedException {
|
||
|
synchronized(o) {
|
||
|
o.wait(5001);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@UiThread
|
||
|
void waitOnMainWithExcessiveTimeout2Bad() throws InterruptedException {
|
||
|
synchronized(o) {
|
||
|
o.wait(4000, 2000000000);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
Object lock, x;
|
||
|
|
||
|
@UiThread
|
||
|
void indirectWaitOnMainWithoutTimeoutBad() throws InterruptedException {
|
||
|
synchronized(lock) {}
|
||
|
}
|
||
|
|
||
|
void lockAndWaitOnAnyWithoutTimeoutBad() throws InterruptedException {
|
||
|
synchronized(lock) {
|
||
|
synchronized(x) {
|
||
|
x.wait();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|