> -----Original Message----- > From: Alex Young [mailto:[EMAIL PROTECTED] > Sent: 31 March 2003 13:11 > To: [EMAIL PROTECTED] > Subject: WebServer handler threads > > > Hi, does anyone know if there is a way to make the server side handlers > multi-threaded. By default when you try to access a particular method on > the server, that method is always run from the same object creating a > potential bottleneck. I realise the Connection objects spawned by the > WebServer run in their own thread but I dont see how this will avoid the > Handler bottleneck. > > Can anyone throw some light on this?
I'm not sure about the http server in xmlrpc but in theory, and unless the handler methods ae synchronised, more than one connection handler thread can simultaneously call methods in your single handler object, or the static code in a Class. This is pretty much the reason "synchronised" exists, the default behaviour is the threaded behaviour _you_ want, if you want to restrict calls to a method so that they are only made one at a time then you have to synchronise the sensitive parts. The "best" (in that it obeys the principle of least surprise) solution is to ensure that wherever possible your methods are "thread-safe", often this distills down to simply being sensible about the scope of variables, and assume that your methods may be called by more than one thread at a time. Save synchronisation for times where you may be reading or writing the state of objects which have state, I assume your handlers don't. d.