Use the threading module instead of thread

The thread module is not present in python3, hence it is not portable
between python2 and python3.