Java multithreading takes too long to process business code example

Background: an application system has been developed in the government. Its main function is to allow enterprises to fill in enterprise qualification information, and then count this series of information through a given formula, which is displayed to government leaders in the form of scores. At present, 1300 enterprises have filled in. Because the score is displayed in real time, the statistical function is very slow@ H_ 301_ 1@

Code running process: @ h_ 301_ 1@

1. Find out 1300 enterprise information @ h_ 301_ 1@

2. Traverse 1300 enterprise information and Ji calculate the score information of each enterprise. The estimated time of each house is 0.3 seconds. 390 seconds in total. Cause page request timeout @ h_ 301_ 1@

3. Export (with JXL jar) @ h_ 301_ 1@

Solution: @ h_ 301_ 1@

Due to the complexity of processing business, a thread with return value is required. Use: Callable@H_301_1 @

Direct up code @ h_ 301_ 1@

1. Calling thread code @ h_ 301_ 1@

2. Thread code @ h_ 301_ 1@

Note: mycallable is just a complex business processing method. Negligible. Finally, speed up from 390 seconds to 40 seconds@ H_ 301_ 1@

Summary @ h_ 301_ 1@

The above is all about the solution code example of Java multithreading execution and processing business for too long. I hope it will be helpful to you. Interested friends can continue to refer to other related topics on this site. If there are deficiencies, please leave a message to point out. Thank you for your support@ H_ 301_ 1@

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>