Use thread instead of forking