Add threads and conditions to example code