gpt4 book ai didi

java - JPype 不能在线程内工作?

转载 作者:太空狗 更新时间:2023-10-30 02:05:54 24 4
gpt4 key购买 nike

我测试了一个简单的 hello world 行来测试 JPype:

jpype.java.lang.System.out.println(" Hello World ")

它在“主”python 程序的上下文中运行良好。但是,在运行线程的上下文中,我得到以下响应:

#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f5272aeb226, pid=7888, tid=139991902578432
#
# JRE version: 7.0_01-b08
# Java VM: Java HotSpot(TM) 64-Bit Server VM (21.1-b02 mixed mode linux-amd64 compressed oops)
# Problematic frame:
# C [_jpype.so+0x33226] JPJavaEnv::FindClass(char const*)+0x36
#
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/imedia/NTsvm/src/server/nlp/hs_err_pid7888.log
#
# If you would like to submit a bug report, please visit:
# http://bugreport.sun.com/bugreport/crash.jsp
#
Aborted

最佳答案

引用自JPype documentation :

Python Threads

For the most part, python threads based on OS level threads (i.e posix threads), will work without problem. The only thing to remember is to call jpype.attachThreadToJVM() in the thread body to make the JVM usable from that thread. For threads that you do not start yourself, you can call isThreadAttachedToJVM() to check.

HTH

关于java - JPype 不能在线程内工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7861299/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com