[英]JNI doesn't work on AppKit Thread
I'm calling a native function from my Swing application on Mac. 我正在Mac上的Swing应用程序中调用本机函数。 The call comes from AWT-EventQueue-0 thread.
该调用来自AWT-EventQueue-0线程。 I call some async native API and end up in a callback in the AppKit Thread (
[NSThread isMainThread] == TRUE
). 我调用了一些异步本机API,并最终在AppKit线程 (
[NSThread isMainThread] == TRUE
)中进行了回调。 The problem is JNI doesn't work on AppKit thread. 问题是JNI在AppKit线程上不起作用。 For example, call to env->FindClass cases a SIGABRT that crashes my app.
例如,调用env-> FindClass会导致SIGABRT使我的应用程序崩溃。 However, JNI works correctly in the EventQueue thread.
但是,JNI在EventQueue线程中可以正常工作。
How can I execute native callback code inside AWT-EventQueue-0 thread or make JNI work inside AppKit Thread ? 如何在AWT-EventQueue-0线程内执行本机回调代码或如何使JNI在AppKit线程内工作?
OpenJDK 1.7, OS X 10.10, XCode 6.1.1 OpenJDK 1.7,OS X 10.10,XCode 6.1.1
Not sure if this will help as it's hard to know exactly what's going on without more information, but I've run into this problem when I store an env pointer in one thread, and then use that pointer in another. 不知道这是否有帮助,因为如果没有更多信息就很难确切知道发生了什么,但是当我将env指针存储在一个线程中然后在另一个线程中使用该指针时,我就遇到了这个问题。 The different threads need their own env pointers.
不同的线程需要它们自己的env指针。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.