Added locking to set/setException to avoid sync issue