Open mwkirk opened 11 years ago
From sype...@gmail.com on March 01, 2013 17:37:43
Note for future implementation:
The PushQueue should be stoppable gracefully. The runQueue method of NotificationThread (the actual implementation for PushQueue) actually has a switch for shutting down gracefully, but is not exposed to users. A "stop" method should be added to the NotificationThread class, and it should simply set the mode property to something else than QUEUE, hence causing an exit of the runQueue method's primary while loop.
Original author: rthor...@gmail.com (February 23, 2013 00:58:28)
What steps will reproduce the problem?
What is the expected output? What do you see instead? I expect to have a way to stop the underlying NotificationThread; instead, Tomcat reports that my Thread was left running, and will cause a memory leak.
What version of the product are you using? On what operating system? Win7Pro SP1, JavaPNS Version 2.2, Tomcat 7
Please provide any additional information below. The javadocs for the Thread class say we shouldn't use thread.stop(), either. We need more control over the underlying Thread object so we can shut things down gracefully. I tried using NotificationThreads (subclass of ThreadGroup) to use setDaemon(true) and destroy(), but both of these options end up causing IllegalThreadStateException.
I'm not sure why setDaemon(true) isn't working as expected (should cause them to be terminated with the Tomcat context), but perhaps it's because I was setting that on the ThreadGroup rather than directly on the Thread? If I could have a handle on the underlying Thread I could set that manually; alternatively create more Thread-like methods on the NotificationThread class (e.g. setDaemon(boolean), stop()).
Or change "private Thread thread" to "protected Thread thread".
Original issue: http://code.google.com/p/javapns/issues/detail?id=168