There are many solutions to this problem on the Internet and there are now three solutions available for your reference. The detailed implementation of each method can be supplemented with time. 1 thread between the code merge do a good job of synchronization, to prevent the pan abused 2 with thread pool, to solve multithreading high concurrency 3 and the use of asynchronous method 3.1 asynchronous is to solve multithreading high concurrency.
Multiple operations can be posted to a thread or several threads to complete. The typical asynchronous operation under Windows is IOCP (completion port), which can greatly improve performance. The implementation mechanism is the request to the kernel, the immediate completion of the request (do not block, reduce the operating system blocking the queue to the ready queue of the scheduling), with the completion of data operations call the application layer pass the callback function passed the data. 3.2n#odejs on the invention.