Rewrite state handling in Application
Rewrite state handling in Application

Application was using a boolean isRunning to check if start() had
been called and a ReadWriteLock to see if shutdown() had been called
(plus synchronization for that). It now uses a three state enum as
well as a ReadWriteLock for all actions involving the state.
Some other synchronization has been modified as well.

DesignAndDeploy/dnd,DesignAndDeploy/dnd,DesignAndDeploy/dnd