Menu

#12 Good suggestion about threads

Future Release
open
5
2013-10-03
2009-04-30
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.

     
  • Nobody/Anonymous

    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?

     
  • Nobody/Anonymous

    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;
    }
    

    }

     
  • Nobody/Anonymous

    I have tested the code provided at http://sourceforge.net/projects/olap4j/forums/forum/577988/topic/3247655 and it passes all the tests. I'll try running that through a 1.4 JVM and see what happens with retroweaver. I suspect it will crash, but I'll make sure it can fallback to 1.4 behavior.

     
  • 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
     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.