support 4 cores and write sample.txt