#12 Good suggestion about threads

Future Release
open
Luc Boudreau
5
2013-10-03
2009-04-30
Luc Boudreau
No

Discussion

  • Julian Hyde
    Julian Hyde
    2009-05-02

    Yes, good idea, we should do it. But watch out for JDK 1.4 compatibility, because ThreadFactory is new in JDK 1.5.

     
  • The ThreadFactory is also available within the jsr 166 backport so it should be possible to
    use this. Will retroweaver mapp j.u.c.ThreadFactory automatically to e.e.m.b.j.u.c.ThreadFactory?

    http://backport-jsr166.sourceforge.net/doc/api/edu/emory/mathcs/backport/java/util/concurrent/ThreadFactory.html

    This is how I would implement it:
    import java.util.concurrent.Executors;
    import java.util.concurrent.ThreadFactory;

    public class DaemonThreadFactory implements ThreadFactory {
    private final ThreadFactory factory = Executors.defaultThreadFactory();

    //@Override
    public Thread newThread(Runnable r) {
        Thread thread = factory.newThread(r);
        thread.setDaemon(true);
        return thread;
    }
    

    }

     
  • Julian Hyde
    Julian Hyde
    2009-05-06

    OK, it should just work then. But it's worth running the test suite under JDK 1.4 before checking in.

    I'd like EVERY thread that olap4j (or drivers for it) creates to come from a pool. It doesn't play nice inside containers if it doesn't. Anyone know how olap4j is supposed to deduce what ThreadPool the container wants it to use?

     
  • The ThreadFactory is also available within the jsr 166 backport so it should be possible to
    use this. Will retroweaver mapp j.u.c.ThreadFactory automatically to e.e.m.b.j.u.c.ThreadFactory?

    http://backport-jsr166.sourceforge.net/doc/api/edu/emory/mathcs/backport/java/util/concurrent/ThreadFactory.html

    This is how I would implement it:
    import java.util.concurrent.Executors;
    import java.util.concurrent.ThreadFactory;

    public class DaemonThreadFactory implements ThreadFactory {
    private final ThreadFactory factory = Executors.defaultThreadFactory();

    //@Override
    public Thread newThread(Runnable r) {
        Thread thread = factory.newThread(r);
        thread.setDaemon(true);
        return thread;
    }
    

    }

     
  • Luc Boudreau
    Luc Boudreau
    2009-09-30

    Apparently, olap4j XMLA driver doesn't work at all on a Java 4 JVM. I wasn't able to confirm this but Xerces doesn't work well in a 1.4 JVM. According to this :

    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-summary.html

    The 1.4 API doesn't have a org.w3c.dom.ranges package and adding the xml-apis library to the classpath causes exceptions about methods not found. Which is to be expected.

    What are my options? Did I miss something? Insights?

     
  • Luc Boudreau
    Luc Boudreau
    2009-09-30

    I'll create a specific ticket about the Java 4 compatibility issue and close this one. I'll commit the patch to the trunk for the threads factory problem.

     
  • Luc Boudreau
    Luc Boudreau
    2013-10-03

    • Group: --> Future Release