Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java在调用tasker.postPipeline().wait()时报错 #502

Open
SCzfdf opened this issue Dec 29, 2024 · 1 comment
Open

java在调用tasker.postPipeline().wait()时报错 #502

SCzfdf opened this issue Dec 29, 2024 · 1 comment

Comments

@SCzfdf
Copy link

SCzfdf commented Dec 29, 2024

    // 调用代码
    new Thread(this::loopScreenshot).start();


    @SneakyThrows
    private void loopScreenshot() {
        try (Tasker tasker = new Tasker()){
            tasker.bind(resource, controller);
            while (true) {
                long now = System.currentTimeMillis();
                TaskFuture<TaskDetail> taskFuture = tasker.postPipeline("screenshot",
                        Map.of("screenshot",
                                Map.of("action", "Custom",
                                        "custom_action", "screenshotAction",
                                        "pre_delay", 0,
                                        "post_delay", 0)
                        ));
                taskFuture.wait();
                TaskDetail taskDetail = taskFuture.get();
                log.info("Screenshot time:{}, result:{}", System.currentTimeMillis() - now, taskDetail);
            }
        }
    }

Exception in thread "Thread-2" java.lang.IllegalMonitorStateException: current thread is not owner
at java.base/java.lang.Object.wait(Native Method)
at java.base/java.lang.Object.wait(Object.java:338)
at com.sczfdf.maa.random.dice.handler.StartHandler.loopScreenshot(StartHandler.java:121)
at java.base/java.lang.Thread.run(Thread.java:842)

@MistEO
Copy link
Member

MistEO commented Dec 31, 2024

@hanhuoer 来瞅瞅_(:з」∠)_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants