add synachronization for batch task, still having a bug, to be fixed