sample code which demonstrate the difference between the state of nondetached and the state of detached