public class ForkJoinPoolFactoryBean extends Object implements org.springframework.beans.factory.FactoryBean<ForkJoinPool>, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
FactoryBean
that builds and exposes a preconfigured ForkJoinPool
.
May be used on Java 7 as well as on Java 6 with jsr166.jar
on the classpath
(ideally on the VM bootstrap classpath).
For details on the ForkJoinPool API and its use with RecursiveActions, see the JDK 7 javadoc.
jsr166.jar
, containing java.util.concurrent
updates for Java 6, can be obtained
from the concurrency interest website.
Constructor and Description |
---|
ForkJoinPoolFactoryBean() |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
void |
destroy() |
ForkJoinPool |
getObject() |
Class<?> |
getObjectType() |
boolean |
isSingleton() |
void |
setAsyncMode(boolean asyncMode)
Specify whether to establish a local first-in-first-out scheduling mode for forked tasks
that are never joined.
|
void |
setParallelism(int parallelism)
Specify the parallelism level.
|
void |
setThreadFactory(ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory)
Set the factory for creating new ForkJoinWorkerThreads.
|
void |
setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
Set the handler for internal worker threads that terminate due to unrecoverable errors
encountered while executing tasks.
|
public void setParallelism(int parallelism)
Runtime.availableProcessors()
.public void setThreadFactory(ForkJoinPool.ForkJoinWorkerThreadFactory threadFactory)
ForkJoinPool.defaultForkJoinWorkerThreadFactory
.public void setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler uncaughtExceptionHandler)
public void setAsyncMode(boolean asyncMode)
true
) may be more appropriate
than the default locally stack-based mode in applications in which worker threads only
process event-style asynchronous tasks. Default is false
.public void afterPropertiesSet()
afterPropertiesSet
in interface org.springframework.beans.factory.InitializingBean
public ForkJoinPool getObject()
getObject
in interface org.springframework.beans.factory.FactoryBean<ForkJoinPool>
public Class<?> getObjectType()
getObjectType
in interface org.springframework.beans.factory.FactoryBean<ForkJoinPool>
public boolean isSingleton()
isSingleton
in interface org.springframework.beans.factory.FactoryBean<ForkJoinPool>
public void destroy()
destroy
in interface org.springframework.beans.factory.DisposableBean