On 7/11/07, Trustin Lee <[EMAIL PROTECTED]> wrote:
On 7/11/07, Michael Bauroth <[EMAIL PROTECTED]> wrote: > Hi, > > just a short question: The IoSessionHandler will be called in most cases > from concurrent threads in the same time. Right? I ask, because I have > to implement in this case some sort of synchronization in each of the > methods (messageReceived ...) If the number of connection is greater than 1, yes. If you are accessing a shared resource in your handler implementation, you need synchronization, which might degrade performance if the shared resource is expensive to access.
Michael, you could/should try to find the most appropriate synchronization mechanism for your use-case. For instance, when most access to the shared resource is read-only, you could increase performance by using a ReadWriteLock instead of 'ordinary' synchronization. http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReadWriteLock.html Maarten HTH,
Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
