Java Threads mailing list archive
RE: Channels versus Methods
From: "P.H.Welch" <P.H.Welch@ukc.ac.uk>
Date: Thu, 8 Jul 1999 19:08:28 +0100
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.
Last updated: Tue Nov 2 12:11:42 1999
Maintained by Peter Welch.