java - batch insert size :488
PHP中文网
PHP中文网 2017-04-17 17:45:01
0
2
401

spring boot中如果试用多线程,这些线程去执行sql的时候是不是一个一个线程轮流的?
因为我在执行一段代码的时候发现
[pool-5-thread-2] : batch insert size :488
[pool-5-thread-4] : time: 14512 seconds.
[pool-5-thread-4] : batch insert size :1084
[pool-5-thread-1] : time: 20217 seconds.
[pool-5-thread-1] : batch insert size :2030
[pool-5-thread-3] : time: 27216 seconds.
[pool-5-thread-3] : batch insert size :1034
这里time时间是执行sql所用时间,time是累加的。如果每条线程执行sql不是轮流来的,那么这个time不应该是累加的啊

PHP中文网
PHP中文网

认证0级讲师

reply all(2)
黄舟

Is your insert statement inserting into a table? If it is a table, the locking mechanism of the database can only insert in turns

洪涛

It depends on how you calculate time. It is thread local and thread share variable.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template