Avoid possible race condition when accessing 16-bit AVR register.
Improving queue handling. Cleaning up Alarm and Thread.

1. Reduce alarm and thread delay queue handling.
2. Make alarm example sketch easier to understand.