[
https://issues.apache.org/jira/browse/UIMA-6129?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16937686#comment-16937686
]
li Gongrong commented on UIMA-6129:
-----------------------------------
{code:java}
package com.test.uima;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.apache.uima.UIMAException;
import org.apache.uima.fit.factory.JCasFactory;
import org.apache.uima.fit.util.JCasUtil;
import org.apache.uima.jcas.JCas;
import org.apache.uima.jcas.tcas.Annotation;
public class Main {
public static void main(String[] args) throws UIMAException {
JCas jcas = JCasFactory.createJCas();
ExecutorService executorService = Executors.newFixedThreadPool(10);
jcas.setDocumentText("abcdefg");
FutureTask<String> future = new FutureTask<>( () -> {
long t = System.currentTimeMillis();
while (System.currentTimeMillis() - t <= 1000L) {
Annotation annotation = new Annotation(jcas, 0, 2);
annotation.addToIndexes(jcas);
}
return "success";
});
executorService.execute(future);
try {
future.get(20, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
e.printStackTrace();
} catch (TimeoutException e) {
future.cancel(true);
e.printStackTrace();
}
System.out.println(JCasUtil.select(jcas, Annotation.class).size());
System.out.println("Finished select");
System.out.println(JCasUtil.selectCovered(jcas, Annotation.class, 0,
5));
System.out.println("Finished select covered");
System.out.println(JCasUtil.selectCovering(jcas, Annotation.class, 0,
1));
System.out.println("Finished select covering ");
executorService.shutdown();
}
}
{code}
I can't recurrent the jstack in my complex code, but the simple code may
caused *ConcurrentModificationException* , is it the same exception? when i do
some thing in JCas index and the kill the thread, it will case multy thread
exceptions?
> The thread may deadlock if other thread interrupted which use jcas
> -------------------------------------------------------------------
>
> Key: UIMA-6129
> URL: https://issues.apache.org/jira/browse/UIMA-6129
> Project: UIMA
> Issue Type: Bug
> Components: UIMA
> Affects Versions: 2.10.4SDK
> Reporter: li Gongrong
> Priority: Major
>
> I use FutureTask to kill the thread spend a lot of time,but it will cause
> deadlock.
> {code:java}
> at sun.misc.Unsafe.park(Native Method)at sun.misc.Unsafe.park(Native Method)
> - parking to wait for <0x000000070435e808> (a
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject) at
> java.util.concurrent.locks.LockSupport.park(LockSupport.java:175) at
> java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2039)
> at
> org.apache.uima.jcas.impl.JCasHashMapSubMap.getReserve(JCasHashMapSubMap.java:303)
> at org.apache.uima.jcas.impl.JCasHashMap.getReserve(JCasHashMap.java:318) at
> org.apache.uima.jcas.impl.JCasImpl.getJfsFromCaddr(JCasImpl.java:1154) at
> org.apache.uima.jcas.impl.JCasImpl$JCasFsGenerator.createFS(JCasImpl.java:912)
> at
> org.apache.uima.jcas.impl.JCasImpl$JCasFsGenerator.createFS(JCasImpl.java:873)
> at org.apache.uima.cas.impl.CASImpl.ll_getFSForRef(CASImpl.java:3751) at
> org.apache.uima.cas.impl.CASImpl.createFS(CASImpl.java:2231) at
> org.apache.uima.cas.impl.FSIteratorWrapper.get(FSIteratorWrapper.java:63) at
> org.apache.uima.cas.impl.FSIteratorAggregate.get(FSIteratorAggregate.java:76)
> at
> org.apache.uima.cas.impl.FSIteratorImplBase.next(FSIteratorImplBase.java:66)
> at
> org.apache.uima.cas.impl.FSIteratorImplBase.next(FSIteratorImplBase.java:32)
> {code}
> why ?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)