[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Channels versus Methods
Amazing that however many times you read something through before posting,
you always find a silly immediately afterwards ...
> Or we can simply lock the CALL sequence using the channel object (which
> can therefor remain just 1-1):
>
>
> synchronise (c) {
> c.write (null); // ready to make the CALL
> Thing result = B.calculate (...); // or some other Foo method
> c.write (null); // the CALL is complete
> }
That's silly because locking on the channel itself will screw up the internal
algorithms that implement it! I just grabbed the channel for convenience.
A new one should have been used:
Object c.lock = new Object ();
and then:
> synchronise (c.lock) {
> c.write (null); // ready to make the CALL
> Thing result = B.calculate (...); // or some other Foo method
> c.write (null); // the CALL is complete
> }
This was done correctly later in the posting (see One2ManyCallChannel).
Cheers,
Peter.