Add initial support for multi-threading.