Used the pthread_setcancelstate function to configure where the thread can be cancelled.
Added a mutex unlock in the exception catch in the thread to avoid blocking when an error occurs.
Added a mutex unlock in the exception catch in the thread to avoid blocking when an error occurs.