Adding a test case that forks off a lot of parallel branches.

... in an attempt to exaggerate the problem.

https://gist.githubusercontent.com/kohsuke/1853b6c2052d01dcaf92/raw/e87e2dad2b2a3f07f3f67bd42f4f6c5fdecbd6e7/gistfile1.txt
Revisting the threading model.

Designate a thread as a CPS VM execution thread, and ensure that various critical methods can be only invoked from that thread.

With that assertion in place, remove locks that results in a deadlock such as https://trello.com/c/7aTFYWM5/26-intermittent-deadlock
and https://gist.githubusercontent.com/kohsuke/1853b6c2052d01dcaf92/raw/e87e2dad2b2a3f07f3f67bd42f4f6c5fdecbd6e7/gistfile1.txt
Lock reduction

GraphListener might do anything, so don't call it while holding a lock
Acting on CpsThreadGroup from CpsFlowExecution is a common pattern, so create an idiom

... to schedule a task in CpsVmThread
Fixed a race condition.

There's a time lag between

(A) FlowExecution.isComplete() starts returning true,
(B) Future from scheduleRun() signals completion, and
(C) WorkflowRun.finish() call happens to set the final result.

It used to be that the order in which this happens was (A) > (C) > (B)
because head updates and listener notifications happen before Future
signals.

With the change in the previous commit, now the order of the event is
(A) > (B) > (C), which breaks various tests that expect WorkflowRun
to have the final result when CpsFlowExecution completes.

This change fixes back the order.
Cleaning up remaining test failures.

They are all test problems.
shutdown the executor pool when CpsThreadGroup is done
if a file doesn't exist, serve something empty
Fixed a race condition.

execution.isComplete() becomes true before all the listeners are invoked (which is necessary
because the nodes have to appear as heads before the listener can be called.)

When it happens, waitForCompletion() would return, causing the flyweight executor to quit,
making QueueTaskFuture to be marked as done. All this happen before finish() method gets
called and set the result.

In this change, I'm making waitForCompletion() actually wait until the finish() method runs.
Reducing the # of branches.

Otherwise Jenkins seems to have trouble building this in a timely
fashion
Merge branch 'master' into single-thread

Conflicts:
	job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java
Merge remote-tracking branch 'origin/single-thread'

This branch ensures that CPS program execution and relevant state change
happens from a single thread. This eliminates locks, and generally
reduce the likelihood of a deadlock problem.

Conflicts:
	cps/src/main/java/org/jenkinsci/plugins/workflow/cps/CpsThreadGroup.java
	job/src/main/java/org/jenkinsci/plugins/workflow/job/WorkflowRun.java