This version should be faster than the first as it creates two threads at program startup and simply suspends or resumes operation when required which has a lot less overhead than creating and destroying threads of a cyclical basis.
[attachment deleted by admin]