Add define to allow disabling threading entirely

This is useful when using a purely iostream-based client.

This is a temporary fix for issue #338.