Fix multi-thread issue in localmsg API