Home > Back-end >  Interview questions: "unreasonable" on the server
Interview questions: "unreasonable" on the server

Time:10-01

Calculation of the irrational server:
A server, can be launched from a user request (a StartServlet processing the request), began to calculate Pi or irrational Numbers (according to the incoming parameters determine the) such as e, as is known to all, this is an endless process, the user can initiate a request to terminate (StopServlet to deal with this request), termination of the calculation, how to implement this system?

CodePudding user response:

The same user can send multiple Start at the same time? Also is a beginning have not finished processing, and continue to send a start processing?
Actually just a simple problem of asynchronous communication and task status records is background request received Start is to insert a table tasks, status to not perform, the background have a processing circulation monitoring task list and Start processing, change status to implementation, update the currently executing tasks at the same time the batch id or thread id, etc., when I received the Stop request is to find the user to perform the task, to Stop the relevant batch or thread, and modify the status to terminate or delete task can, if a user can Start times at the same time, then according to the demand of the Stop position to Stop the task object; If consider the load performance of background task, try to Start a queue cache requests, etc.,

CodePudding user response:

reference 1st floor qybao response:
the same user can send multiple Start at the same time? Also is a beginning have not finished processing, and continue to send a start processing?
Actually just a simple problem of asynchronous communication and task status records is background request received Start is to insert a table tasks, status to not perform, the background have a processing circulation monitoring task list and Start processing, change status to implementation, update the currently executing tasks at the same time the batch id or thread id, etc., when I received the Stop request is to find the user to perform the task, to Stop the relevant batch or thread, and modify the status to terminate or delete task can, if a user can Start times at the same time, then according to the demand of the Stop position to Stop the task object; If consider the load performance of background task, try to Start a queue cache requests, etc.,

Well, really is more than users start, the key is how this in a multithreaded environment, combined with the Servlet to manage a user computing for many times, very meng,
  • Related