encode multithread