Everyone knows that tokio runtime can be setup to run on the currently running thread by using #[tokio::main(flavor = "current_thread").
However, it does spawns two more threads. Resulting the application runs on three threads.
How do I force tokio to use currently running thread (i.e main thread) and not to spawn additional threads?
I know the other threads are used for blocking operations, such as file I/O. Still, if it's possible for me to disallow tokio to spawn additional threads, let me know.
The current-thread runtime does not automatically spawn two additional threads. The threads you're talking about have to do with the spawn_blocking threadpool, but threads there are spawned on demand, and exit when not used. To avoid these threads, don't use operations that require them.
There isn't any way to disable the spawn_blocking threadpool. If you could, it would break things like tokio::fs entirely.