capotej/monoloco — pull request #2 by eribeiro (2012-09-15 01:11:38+00:00)
Title: Major refactorings

There are quite a few changes here so read below and test those changes under a different branch from *master* because I may have broken something. The code compiles tough. :o)

Firstly, I replaced the 'legacy' Timer by ScheduledExecutorService. The reason is well exposed on StackOverflow: http://stackoverflow.com/questions/409932/java-timer-vs-executorservice . As a side-effect, the class extends Runnable instead of TimerTask.

Secondly, the duration() initially returned milliseconds, but taking advantage of Scala tuples it's possible to return (time, TimeUnit) and to use the clever TimeUnit.{SECONDS, MINUTES, MILLISECONDS}.sleep(time) to sleep for a given time besides making the code more clear.

Finally, there's no need to a Worker as of now (it can be in the future though) because you can make Monkey extends Runnable and put run() method there. To avoid that a subclass mess up with run() and execute() the word 'final' should be added. There's no need to Worker now so I removed it.

Last but not least, I've added the Eclipse project files to the list of .gitignore

If everything is OK then I can push a couple of enhancements that I am thinking right now. ;-)