JNI - 自动将所有新生成的线程从进程附加到 JVM?
我使用 JNI 从 Java 调用 dll。该 DLL 调用另一个第三方库,该库生成一堆线程并向我的 dll 发送回调。我希望将这些回调附加到 JVM。最好的方法是什么?我认为由于线程调用回调方法,回调没有附加到JVM,所以我必须附加它?
难道没有……继承,就像这个线程创建的所有线程都会自动附加到JVM上一样吗?
我查看了文档,但找不到它。
谢谢
I call a dll from Java using JNI. The DLL calls another thirdparty library which spawns a bunch of threads and sends callbacks to my dll. I want these callbacks to be attached to the JVM. What is the best way to do this? I think since the threads call the callback method, the callbacks aren't attached to the JVM, so I have to attach it?
Is there no... inheritance, like all threads created by this thread will automatically attached to the JVM?
I've looked at the documentation but I can't find it.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须从需要调用 VM 的每个线程手动调用
AttachCurrentThread()
(和DetachCurrentThread()
)。没有自动机制。You have to manually call
AttachCurrentThread()
(andDetachCurrentThread()
) from each thread that needs to call into the VM. There is no automatic mechanism.