Added threading support.

Signed-off-by: Tristan Strathearn <r3oath@gmail.com>