multithreading in comparison and writing