Added cancel functionality to the higher level threading library.