Multithreading added

Added multithreading support