java random delayed execution
某草草
某草草 2017-05-27 17:40:47
0
5
875

How to delay the execution of a program and specify the delay time for access, such as recording the request after receiving the request, so that subsequent operations can be delayed for one day

某草草
某草草

reply all(5)
巴扎黑

You can use the scheduling framework quartz

为情所困

1. Record the data received in the database

2. Under Linux, you can use crond to check scheduled tasks and call the trigger task interface provided by java

3. Add the task to redis and use java for scheduled processing.

洪涛

Create a thread upon receiving a request and execute it after a fixed delay using the ScheduledThreadPoolExecutor method.

伊谢尔伦

Quartz in SpringMVC can freely configure multiple scheduled tasks

仅有的幸福

If it is a Java Web project, start a Servlet in the background,
For example
<servlet><servlet-name>servlet的名字</servlet-name><servlet-class>servlet所在的包的路径</servlet-class> <load-on-startup>1</load-on-startup></servlet>

And maintain a thread pool in the background, add requests that need to be delayed to the thread pool, and add a time stamp to each thread for subsequent inspection. The Servlet regularly takes out threads from the thread pool to check whether it should be executed. If If the execution condition is met, it will be executed. If it is not met, the thread will be put back into the thread pool. If it is not a web project, you can use Java's Timer. At the same time, you can maintain a thread pool and use Timer to check regularly.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!