Java Executor服务可调用返回散列错误

时间:2014-12-29 14:03:38

标签: java executorservice callable

我在Java multithreadig 执行者服务中遇到问题。我已实现Callable进行多线程任务。根据我的知识,我不必为put()使用任何concurrentHashMap或SynchronisedMap,因为两个线程都没有使用相同的Map。   我的问题是,如果我的线程使用嵌套方法来获取结果,这可能是一个问题。我的代码是这样的:

public TreeMap2 method3 implements Callable(TreeMap1){
    TreeMap2 = method2(TreeMap1);
    return TreeMap2
}

public TreeMap2 method2(TreeMap1){
    TreeMap = method1(TreeMap1)
    //Do some work
    return TreeMap2
}


public TreeMap method1(TreeMap1){
    // Do some work
    return TreeMap;
}

然后将整个任务分为4个线程并由InvokeAll调用。但这会引发与Hashing相关的错误,如:

Exception on pipe 27. java.lang.ArrayIndexOutOfBoundsException: 563893
java.lang.ArrayIndexOutOfBoundsException: 563893
at gnu.trove.TObjectIntHashMap.rehash(TObjectIntHashMap.java:171)
at gnu.trove.THash.postInsertHook(THash.java:243)
at gnu.trove.TObjectIntHashMap.put(TObjectIntHashMap.java:148)
at edu.umass.cs.mallet.base.types.Alphabet.lookupIndex(Alphabet.java:107)
at edu.umass.cs.mallet.base.types.AugmentableFeatureVector.<init>(AugmentableFeatureVector.java:88)
at edu.umass.cs.mallet.base.types.FeatureVectorSequence.<init>(FeatureVectorSequence.java:39)
at edu.umass.cs.mallet.base.pipe.TokenSequence2FeatureVectorSequence.pipe(TokenSequence2FeatureVectorSequence.java:60)
at edu.umass.cs.mallet.base.pipe.SerialPipes.pipe(SerialPipes.java:141)
at edu.umass.cs.mallet.base.pipe.SerialPipes.pipe(SerialPipes.java:217)
at edu.umass.cs.mallet.base.types.Instance.<init>(Instance.java:105)
at edu.umass.cs.mallet.base.types.InstanceList.add(InstanceList.java:741)
at de.bonn.limes.gcam.abner.MyTagger.doTagging(MyTagger.java:445)
at de.bonn.limes.gcam.abner.MyTagger.getEntities(MyTagger.java:297)
at de.bonn.limes.core.AbnerAnalysis.NERanalysis(AbnerAnalysis.java:84)
at de.bonn.limes.core.AbstractTagger.tagAbstracts(AbstractTagger.java:62)
at de.bonn.limes.core.ListOperations$AbnerCallable.call(ListOperations.java:51)
at de.bonn.limes.core.ListOperations$AbnerCallable.call(ListOperations.java:38)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

我的原帖是Java Executor service concurrency issue。 谢谢你的帮助。

0 个答案:

没有答案