rewrite OnSubscribeRefCount to handle synchronous source

Resubmitting this one having stuffed up the rebase.

Rewrite of ```OnSubscribeRefCount``` because original didn't handle synchronous source (#1688) and as far as I could see the original was fundamentally broken by this use case. Please note also includes a fix in ```OperatorMulticast``` where a null check was required. I've done the rewrite using locks rather than submit a lock-free version just to ensure that the approach is valid with the experts first.
Hi Ben. I started with a failing unit test against 0.20.4 and in the
process may have removed a timeout from the test. I suspect you are seeing
a hanging test instead. Could you do a quick check again with a timeout?
I'm OK to make comments but I am in Tonga on holiday till 17 October
without computer so can't modify the commit with any confidence.
On 3 Oct 2014 11:40, "Ben Christensen" <notifications@github.com> wrote:

> In rxjava-core/src/test/java/rx/RefCountTests.java:
>
> > @@ -237,4 +242,49 @@ public Integer call(Integer t1, Integer t2) {
> >          ts2.assertNoErrors();
> >          ts2.assertReceivedOnNext(Arrays.asList(30));
> >      }
> > +
> > +    @Test
> > +    public void testRefCountUnsubscribeForSynchronousSource() throws InterruptedException {
>
> This test passes for me already, without the changes above.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/ReactiveX/RxJava/pull/1695/files#r18372633>.
>