Executor: stop jobs in parallel on shutdown

When shutting down, tell all of the jobs to stop, then wait for
all of them to complete.

Also, add a lock around starting jobs so that the list of running
jobs is guaranteed to be consistent.

Also fix a shutdown sequencing bug.  It was possible for us to shut down
the internal repo update thread while jobs were still waiting on it.  This
would cause those jobs never to stop.  Fix this by ensuring that we get
no new jobs, then stop all the jobs, then stop the update thread.

Because we want to wait for the update thread to complete, we join it in
the stop() method.  That seems to make the join() method redundant, so
move all of the joins to stop().

Change-Id: I12422d3b445892be3e50963c9edafe3904698bff
1 file changed