Optimized tile selecting thread.

The thread now only executes when it is needed. No resources are wasted
anymore by an infinite loop.