Added pthread dependency, and multithreading support