Demo Applications  Coding Examples  Vole Tutorials  


TeaTimer - a simple application to demonstrate accurate timing

This application shows how to implement a clock using deadlines. If you don't have an RTC or similar time counting device it is nearly impossible to design an application with accurate timing or equidistant time steps with a standard JAVA™ environment. You can do a sleep() for a second and then draw the clock again, then wait for another second, but while drawing there's time lost and you can't know how much it is. Even more JAVA™ is multi-threaded, so you can't know if another thread is stealing some more time of your seconds.

Screenshot of the TeaTimer running on the JControl simulator

Using JControl deadlines you can specify that counting a second takes exacly one second, it is up to the virtual machine to guarantee this timing.


After startup you can set the brewing time using up/down (defaults to 3 mins), after pressing select the clock starts ticking. If the selected time span expires the buzzer beeps a couple of times, pressing a key aborts beeping and the program starts again but with the duration selected before. It is possible to break the count-down holding the "up" key.