Support Python 3.x

Use threading instead of renamed _thread module.