Results 1 to 3 of 3

Thread: ThreadPoolTaskExecutor implements Executor but not ExecutorService

  1. #1
    Join Date
    Jan 2005
    Posts
    9

    Default ThreadPoolTaskExecutor implements Executor but not ExecutorService

    Hi all,

    The other day I was using org.springframework.scheduling.concurrent.ThreadPo olTaskExecutor as a Spring entry point to java.util.concurrent. This class "allows for configuring a JDK 1.5 java.util.concurrent.ThreadPoolExecutor in bean style" (JavaDocs).

    This class wraps and delegates-to an instance of java.util.concurrent.ThreadPoolExecutor . I noticed that ThreadPoolTaskExecutor implements java.util.concurrent.Executor, but it does not implement the sub-interface java.util.concurrent.ExecutorService, which is declared by the wrapped instance java.util.concurrent.ThreadPoolExecutor. This prevented me from using the bean as an ExecutorService - I was limited to the Executor interface. As a result I eventually switched to a factory method on java.util.concurrent.Executors to declare my bean.

    ExecutorService exposes a number of useful methods, particularly shutdown(). If ThreadPoolTaskExecutor implemented ExecutorService, it would need to delegate the additional (12) methods to the underlying ThreadPoolExecutor, but presumably no big deal with that.

    Opinions? Is it worthwhile implementing ExecutorService in ThreadPoolTaskExecutor so that the full interface of ThreadPoolExecutor is exposed?

    Cheers
    Brett

  2. #2
    Join Date
    Nov 2004
    Location
    Hilversum - The Netherlands
    Posts
    1,054

    Default

    If you can use Java 5, there is no reason (as far as I know) not to use the java concurrency functionality directly. So I would drop the Spring stuff.

  3. #3
    Join Date
    Jan 2005
    Posts
    9

    Default

    Thanks for your reply.

    Fair enough, and as mentioned, this is what I ended up doing. I am of the opinion that it wouldn't hurt for ThreadPoolTaskExecutor to implement ExecutorService, and that this would make this class more useful.

    Cheers
    Brett

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •