Code of writer thread.