Multi-threading support

Added support to adjustable thread count