Changed code  in threading to prepare linux implementation.