use cmake threads find_package macro

great sample code. Minor proposal to use cmake macro for pthreads flags