Segmentation trying to use multithread