Single thread vs thread pool

Hi, guys.

I’m working on a project of simple network game server. The point is: the server can host several game sessions. For example: 20 users can play chess simultaneously on 10 boards.

I’ve come to an issue that seems nontrivial to me. I’m making decision between single-threaded architecture vs thread-pool architecture of turn processing. The point is: single threaded architecture is far easier to implement (you don’t have to care about synchronization) but thread-pools looks like more robust. For example if (for some weired reason) turn processing took more then usual for one board: then all boards will suffer from delay (because all requests are processed in one thread). There’s no such problem with thread-pools.

Tomcat uses thread pools to process requests. HSQLDB uses single-threaded architecture.
I’m bit confused, plz help.

You should have a thread pool that uses one thread per board. Since the boards will each have separate data, there shouldn’t be many issues with synchronization.

If you’re concerned, then you could just have two threads to cover everything: one that does the execution, and a second that interrupts the first every X milliseconds, forcing it to move onto the next game.