1: First Configure the thread pool (configured in the spring configuration file, I am configured in applicationcontext.xml)
<!-- Async thread pool --><bean id= "Taskexecutor" class= " Org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor "> <!-- Number of core threads --> <property name= "Corepoolsize" value= "5" /> <!-- Maximum number of threads --> <property name= "Maxpoolsize" value= /> <!-- Queue Maximum length >=mainexecutor.maxsize -- > <property name= "queuecapacity" value= " /> " <!-- thread pool to maintain idle time allowed by thread --> <property name= " Keepaliveseconds " value=" /> <!-- thread pool processing policy for rejected tasks (wireless path available) - -> <property name= "Rejectedexecutionhandler" > <bean class= "Java.util.concurrent.threadpoolexecutor$callerrunspolicy" /> </property ></bean>
2: Inject Taskexecutor and use
Throws a thread directly into the thread pool, which controls when it is started and automatically calls its Run method
3: Thread Interface (responsequeuethread)
To this end, haha, very simple, welcome all kinds of spit groove, have better also please recommend, thank you! Thank you
Spring threadpooltaskexecutor thread Pool