fix thread starvation bug