繁体   English   中英

IllegalMonitorStateException: 对象在 wait() 之前未被线程锁定,使用同步静态方法

[英]IllegalMonitorStateException: object not locked by thread before wait(), using synchronized static method

我已经读过这个问题,但我认为我的情况有所不同: IllegalMonitorStateException on wait() call

我在 Android Studio 上使用 java。 我得到的错误如下:

MiniatureAnnotations: Problem annotating via GMS.
    java.lang.IllegalMonitorStateException: object not locked by thread before wait()
        at java.lang.Object.wait(Native Method)
        at java.lang.Object.wait(Object.java:422)
        at jaw.a(PG:20)
        at hnt.b(PG:115)
        at com.google.android.apps.messaging.shared.datamodel.action.GenericWorkerQueueAction.b(PG:81)
        at eqs.run(PG:1)
        at yya.run(PG:3)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at yws.run(PG:4)
        at java.lang.Thread.run(Thread.java:764)

我没有在对象上使用锁,而是同步了方法。 如:

public synchronized static boolean send(Repository repository, Context context) {
   //  code... [I do not use wait or notify]
}

或者:

 public static synchronized void checkWorkers(Context context) {
        WorkManager workManager = WorkManager.getInstance(context);
        ListenableFuture<List<WorkInfo>> senderWorker = workManager.getWorkInfosByTag(tagSenderWorker);
        if (senderWorker.isCancelled()) {
            PeriodicSmsWorker.initializePeriodicSmsWorker(context, REPLACE_POLICY);
            updateCheckSenderWorker();
    } else if (System.currentTimeMillis() - LAST_CHECK_SENDER_WORKER > MAX_TIME_WORKER_INACTIVE) {
        updateCheckSenderWorker();
        PeriodicSmsWorker.initializePeriodicSmsWorker(context, REPLACE_POLICY);
    }
}

如果我不使用等待或通知,为什么会收到 IllegalMonitorStateException?

编辑 1:禁用 Dexguard 基于: 如何禁用 Dexguard?

在gradle应用程序中:

buildTypes {
        release {
            //minifyEnabled false
            minifyEnabled rootProject.ext.enableDexGuardPlugin
            //proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
dependencies {
    ...
    apply plugin: 'com.android.application'
    if(rootProject.ext.enableDexGuardPlugin) {
        apply plugin: 'dexguard'
    }
}

毕业项目:

 ext {
        roomVersion = '2.2.0-beta01'
        archLifecycleVersion = '2.2.0-alpha03'
        coreTestingVersion = "2.1.0-rc01"
        enableDexGuardPlugin = false
    }

但是我有同样的错误。

wait()的攻击性调用是通过方法jaw.a 如果您找不到它的真实名称,请禁用 DexGuard,重新构建并再次运行您的应用程序。 堆栈跟踪应该显示调用没有synchronized wait()的确切位置。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM