DWR

create all DWR threads as daemon threads

Details

  • Type: Improvement Improvement
  • Status: Resolved Resolved
  • Priority: Normal Normal
  • Resolution: Fixed
  • Affects Version/s: 2.0.5, 3.0.RC1
  • Fix Version/s: None
  • Component/s: Core
  • Documentation Required:
    No
  • Description:
    Hide
    All DWR threads should create a daemon threads. The JVM might not exit till all non-daemon threads are dead (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html). Starting threads this way should cut down on all the servlet hackery. When using ScheduledThreadPoolExecutor you just need to pass the ThreadFactory below to the constructor in order to have it create a daemon thread.


    public class DaemonThreadFactory implements ThreadFactory {

          public Thread newThread(Runnable r) {
            Thread t = new Thread(r);
            t.setDaemon(true);
            return t;
          }

    }
    Show
    All DWR threads should create a daemon threads. The JVM might not exit till all non-daemon threads are dead (http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Thread.html). Starting threads this way should cut down on all the servlet hackery. When using ScheduledThreadPoolExecutor you just need to pass the ThreadFactory below to the constructor in order to have it create a daemon thread. public class DaemonThreadFactory implements ThreadFactory {       public Thread newThread(Runnable r) {         Thread t = new Thread(r);         t.setDaemon(true);         return t;       } }

Issue Links

Activity

Hide
David Marginian added a comment - 25/Apr/09 6:07 AM

DWR currently creates an AutoShutdownScheduledThreadPoolExecutor which is supposed to (and probably is - since tomcat is shutting down properly) taking care of the proper destruction of all threads - if the DwrListener is registered.

My thinking here is that we can get rid of this code if we use the code recommended by Deno. Thoughts?

Show
David Marginian added a comment - 25/Apr/09 6:07 AM DWR currently creates an AutoShutdownScheduledThreadPoolExecutor which is supposed to (and probably is - since tomcat is shutting down properly) taking care of the proper destruction of all threads - if the DwrListener is registered. My thinking here is that we can get rid of this code if we use the code recommended by Deno. Thoughts?
Hide
Mike Wilson added a comment - 25/Apr/09 11:28 AM

I think we should definitiely try "daemon" out. Having user code not need to add an additional listener in web.xml would be great. Deno is spot on with the ThreadFactory example above.

Show
Mike Wilson added a comment - 25/Apr/09 11:28 AM I think we should definitiely try "daemon" out. Having user code not need to add an additional listener in web.xml would be great. Deno is spot on with the ThreadFactory example above.
Hide
David Marginian added a comment - 28/Apr/09 2:21 AM

I have implemented the daemon thread factory and removed all existing shutdown code (previously used to kill threads). Ready for testing.

Show
David Marginian added a comment - 28/Apr/09 2:21 AM I have implemented the daemon thread factory and removed all existing shutdown code (previously used to kill threads). Ready for testing.

People

Dates

  • Created:
    24/Apr/09 8:17 PM
    Updated:
    28/Apr/09 2:21 AM
    Resolved:
    28/Apr/09 2:21 AM