Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在hasNext()调用时冻结while循环_Java_Debugging_While Loop_Iteration_Jena - Fatal编程技术网

Java 在hasNext()调用时冻结while循环

Java 在hasNext()调用时冻结while循环,java,debugging,while-loop,iteration,jena,Java,Debugging,While Loop,Iteration,Jena,我在调用basichasNext()方法时遇到了一些问题 我不明白为什么会这样。在执行过程中有一段时间,程序将经历3次迭代 StmtIterator statementIt = m.listStatements(null, p, obj); Statement stamt = null; List<Resource> lres = new ArrayList<Resource>(); while (statementIt.hasNext()) { stamt =

我在调用basic
hasNext()
方法时遇到了一些问题

我不明白为什么会这样。在执行过程中有一段时间,程序将经历3次迭代

StmtIterator statementIt = m.listStatements(null, p, obj);
Statement stamt = null;
List<Resource> lres = new ArrayList<Resource>();
while (statementIt.hasNext())
{
    stamt = (Statement)statementIt.next();
    System.out.println("Debugging: " + stamt.getSubject().toString());
    if(!stamt.getSubject().isURIResource())
    {
        break;
    }
    if(!lres.contains((Resource)stamt.getSubject()))
        lres.add((Resource)stamt.getSubject());
    System.out.println("debugging: there will be another iteration: " + statementIt.hasNext());
}
StmtIterator语句it=m.listStatements(null,p,obj);
语句stamt=null;
List lres=new ArrayList();
while(statementIt.hasNext())
{
stamt=(语句)statementIt.next();
System.out.println(“调试:+stamt.getSubject().toString());
如果(!stamt.getSubject().isURIResource())
{
打破
}
如果(!lres.contains((资源)stamt.getSubject())
添加((资源)stamt.getSubject());
System.out.println(“调试:将有另一个迭代:”+statementIt.hasNext());
}
它确实执行了3次,但在尝试执行
hasNext()
操作时挂起。我试图通过debug视图(我使用Eclipse开发Java)查看程序的概要文件,虽然我不是这个调试工具的大师,但我没有找到任何与查明异常来源相关的东西


我在这里不知所措,请发送帮助D:

感谢@user205512和@JoshuaTaylor,我找到了问题所在

我使用了一个reasoner,它会挂起程序寻找更多节点,但从未真正使用过它(默认的Jena包实现了reasoner接口,但没有工作的reasoner)


解决方案:要么放弃使用推理机(在使用本体论时不是很重要),要么找一个合适的推理机并让它工作(我目前正在尝试驯服Pellet推理机:p)

你如何创建你的模型?下一步你是对的。。。删除我的答案。。。对不起的:(模型有多大,您使用的是什么存储?我的第一个怀疑是内存有限,所以请尝试VisualVM了解可能发生的情况。啊,这是一个ontmodel?如果是,这可能很好地解释了暂停,这取决于使用的推理器和本体的性质。@Feillen我认为关于ontmodel和推理器的评论s因为.hasNext()需要确定迭代中是否有其他元素。这可能取决于推理。例如,推理者必须执行推理以确定是否还有其他此类语句。