Fixing a concurrency bug in RunnableProcess

Closes #691:
  * Replaced the two booleans isStarted and isEnded with a state enum
  * Added synchronization on the state
  * Added state transition checks