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.

45 lines
911 B

/*
* 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.
*/
class Parameters {
private static void syncOnParam(Object x) {
synchronized (x) {
}
}
// Next two methods will deadlock
public synchronized void oneWaySyncOnParamBad(Object x) {
syncOnParam(x);
}
public void otherWaySyncOnParamBad(Object x) {
synchronized (x) {
synchronized (this) {
}
}
}
private static void emulateSynchronized(Parameters self) {
synchronized (self) {
}
}
Parameters someObject;
// Next two methods will deadlock
public synchronized void FN_oneWayEmulateSyncBad() {
emulateSynchronized(someObject);
}
public void FN_anotherWayEmulateSyncBad() {
synchronized (someObject) {
synchronized (this) {
}
}
}
}