Since the threads-based approach doens't seem to to working I'm going back to trying to deal with the internal state of wiringPi.