मैं अनुसूचित धागे चलाने के लिए ScheduledExecutorService
का उपयोग कर रहा हूं।
मैंने ServletContextListener.contextDestroyed
लागू किया और ScheduledExecutorService.shutdownNow
और awaitTermination
को लागू किया।टॉमकैट 7 और अनुसूचित एक्सप्लोरर सेवा। शटडाउन
यहाँ एक उदाहरण है:
गंभीर:
@Override public void contextDestroyed(ServletContextEvent servletcontextevent) { pool.shutdownNow(); // Disable new tasks from being submitted try { // Wait a while for existing tasks to terminate if (!pool.awaitTermination(50, TimeUnit.SECONDS)) { pool.shutdownNow(); // Cancel currently executing tasks System.err.println("Pool did not terminate"); } } catch (InterruptedException ie) { // (Re-)Cancel if current thread also interrupted pool.shutdownNow(); // Preserve interrupt status Thread.currentThread().interrupt(); } }
फिर भी, मैं बिलाव 7 से निम्न त्रुटि हो रही है वेब अनुप्रयोग [/ सर्वलेट] एक शुरू कर दिया है प्रकट होता है थ्रेड नामित [टाइमर -0] लेकिन इसे रोकने में विफल रहा है। स्मृति रिसाव बनाने के लिए यह की संभावना है।
क्या इस लॉग को अनदेखा किया जा सकता है? या मैं कुछ गलत कर रहा हूँ?
धन्यवाद
मेरा मतलब है, मेरा विचार है: क्लीनअप रोकने के लिए आपकी ज़िम्मेदारियां कहां हैं? यहाँ और क्या किया जा सकता है? आग की नली के साथ बॉक्स मारा? सभी गंभीरता में, मेरा कहना है कि ऐसा लगता है कि ऐसा लगता है कि आप बस इतना कर रहे हैं कि आप कर सकते हैं ... मैं उस त्रुटि को अनदेखा कर दूंगा। – ControlAltDel
आप मेरी पिछली पोस्ट का उल्लेख कर सकते हैं :) http://stackoverflow.com/questions/9926356/scheduledexecutorservice-when-shutdown-should-be-invoked – lili