Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

9
  • I think my problem is thinking this is more complex then it is. I saw docs.huihoo.com/javadoc/spring/2.0/org/springframework/… and I assumed a ThreadPoolTaskExecutor had a built in queuing mechanism. Commented May 12, 2009 at 14:21
  • 12
    If the queue capacity is greater than 0, it creates a queue, so that the tasks that are fired by a particular TaskExecutor can wait until a thread is available from the pool. The capacity indicates how many spaces are in the queue. If the queue fills up, the executor will block (i.e. the execute method won't return until a space opens up). Here's the doc on the queue: java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/… Commented May 12, 2009 at 15:13
  • 1
    Ah. No, it's all handled for you, as you say. You just call execute over and over and the tasks get queued if necessary. Commented May 12, 2009 at 17:30
  • 1
    Wait, got it, just need to look at the documentation for the Java clases that the Spring classes are based on. java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/… Commented May 12, 2009 at 18:36
  • 2
    To ensure blocking on full queue/pool, you need to set rejectedExecutionHandler to java.util.concurrent.ThreadPoolExecutor.CallerRunsPolicy. Default handler, AbortPolicy, (static.springsource.org/spring/docs/3.0.x/javadoc-api/org/…) aborts tasks instead of block the caller. Commented Jan 11, 2012 at 15:21