से खारिज कर दिया गया है मेरे पास ThreadPoolExecutor
है और मैं इसे एक कार्य सबमिट करता हूं।भविष्य कार्य ThreadPoolExecutor
private ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new ArrayBlockingQueue<Runnable>(1));
इस कोड ThreadPoolExecutor
करने के लिए Runnable
सबमिट करता है।
protected void waitAndSweep(final String symbol) {
runnable = new Runnable() {
public void run() { /* irrelevant code */ }
};
try {
Future<?> self = threadPoolExecutor.submit(runnable);
futures.add(self);
} catch (RejectedExecutionException re) {
/* this exception will be thrown when wait and sweep is called more than twice.
* threadPoolExecutor can have one running task and one waiting task.
*/
} catch (Exception e) {
logEvent(StrategyEntry.ERROR, "waitAndSweep", symbol, "Exception caught...", e);
}
}
निम्न कोड कार्य रोकता है।
protected synchronized void stop(StrategyEntry entry) throws Exception {
for (Object future : futures) {
((Future<?>) future).cancel(true);
}
futures.clear();
threadPoolExecutor.shutdown();
}
समस्या यहाँ है:
टास्क [email protected] java.util.concurrent से अस्वीकार कर दिया: जब मैं काम को रोकने की कोशिश, मैं निम्नलिखित अपवाद हो रही है। ThreadPoolExecutor @ 216393fb [समाप्त, पूल आकार = 0, सक्रिय सूत्र = 0, पंक्तिबद्ध कार्य = 0, पूर्ण कार्य = 1]
क्या आप इस निष्पादक पर कहीं भी 'शटडाउन()' कहते हैं? – RAnders00
हाँ स्टॉप विधि – MMPgm
आप क्षमता 1 के साथ एक बैकिंग कतार बना रहे हैं - क्या वहां कुछ और कार्य पहले से मौजूद है? –