Threading
When you add a handler you need to specify whether you want it to be a single threaded handler or a multithreaded handler. By default you should use multithreaded handlers (third parameter should be false).
A multithreaded handler means that your handler code will be run by a thread from the server threads pool. Multiple instances of the same handler and other handlers can be executed in the same time. As long as you don't access any global variable out of the current handler instance you should be safe.
A single threaded handler will always be executed by the main thread. This means that if there are multiple requests they will be queued and executed one by one. Single threaded handlers can be useful in many cases. Some examples:
- A handler that accesses a SQLite database, which is less suitable for concurrent connections.
- A handler that writes to a specific file.
- A handler that sends a job to the printer
Note that when you run your code in Debug mode the handlers will always run in the main thread.