È possibile o è gestito da Application Server? Passando l'arbitro ThreadPoolTaskExecutor ad un fagiolo è un gioco da ragazzi, ma cercando di impostare il threadfactory sul l'esecutore di cui sopra sembra avere alcun effetto ...Impostazione Spring 3 ThreadFactory per ThreadPoolTaskExecutor
5
A
risposta
6
In realtà, l'impostazione di un ThreadFactory
è un gioco da ragazzi così:
<bean id="taskExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="threadFactory" ref="threadFactory"/>
</bean>
<bean id="threadFactory" class="org.springframework.scheduling.concurrent.CustomizableThreadFactory">
<constructor-arg value="Custom-prefix-"/>
</bean>
o:
@Bean
public ThreadPoolTaskExecutor taskExecutor() {
final ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
taskExecutor.setThreadFactory(threadFactory());
return taskExecutor;
}
@Bean
public ThreadFactory threadFactory() {
return new CustomizableThreadFactory("Custom-prefix-");
}
noti che ThreadPoolTaskExecutor
estende da ExecutorConfigurationSupport
ed è qui setThreadFactory(java.util.concurrent.ThreadFactory)
è definita.
+0
Perfetto! Questo funziona. Grazie Tomasz. –
e qual è la tua domanda? Per favore chiariscilo. –