Bug fix:cleanup in multi-thread