passed without kkt filter
passed kkt filter
reorder thread join for decent exit
multi-thread version, though it may be slower than the single-thread
version when the data is small