作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我测试了一个简单的 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 callisThreadAttachedToJVM()
to check.
HTH
关于java - JPype 不能在线程内工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7861299/
我是一名优秀的程序员,十分优秀!