Fixed to use received flag instead of Thread.sleep(1000)

Signed-off-by: Tsuyoshi Ozawa <ozawa.tsuyoshi@gmail.com>