Fix multithread issue in localmsg API