About Spring encapsulation Java thread pool Understanding __ Thread pool

Source: Internet
Author: User

The project is Taskexecutor, and I think some of it is configured through the Spring bean. Some of them were configured in a way that looked at the official document, and the official document (as if it were chapter 30.5) was clearly written on the meaning of the parameters inside,

<bean id= "Taskexecutor" class= "Org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" >
	< !--Core Thread Count-->	 
	<property name= "corepoolsize" value= "${task.core_pool_size}"/>
	<!--max Threads-->  
	<property name= "maxpoolsize" value= "${task.max_pool_size}"/>
	<!--queue Maximum length-->
	Name= "queuecapacity" value= "${task.queue_capacity}"/>
	<!--thread pool to maintain the idle time allowed by the thread, by default 60s-->
	< Property Name= "Keepaliveseconds" value= "${task.keep_alive_seconds}"/>
</bean>
<!--callout type-->
<task:annotation-driven/>
<!--or-->
   <task:executor id= "Asynctaskexecutor"
                   Pool-size= "${executor.pool.size}"
                   queue-capacity= "${executor.queue.capacity}"
                   keep-alive= "/>"

As for the configuration/use of the SPRINGMVC consolidated Taskexecutor thread pool
First, configure Jdbc.properties add:

#------------Task------------
task.core_pool_size=5
task.max_pool_size=50
task.queue_capacity=1000
task.keep_alive_seconds=60

Second, configure Spring's applicationcontext.xml add:
is the configuration above.

Declaration and injection of IMPL in the implementation layer:

       

@Resource (name = "Taskexecutor")
    private taskexecutor taskexecutor;

Four, in the method calls:

	try {
			Taskexecutor.execute (new Runnable () {public
				void run () {
					//write Processing business code
					
				}
			}});
		catch (Exception e) {
			e.printstacktrace ();
		}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.