Add support for platforms without threading, fixes #289.