Added thread implementation, fixed memory leakage issue, photo sometimes
hang please fix