More modern interface for threads. Patch by Mikko L.