Hi Pavel, > I'm sorry, but it is a valid scenario - the Calls are not thread safe, but > in this scenario one Call will not be used in more than one thread at the > same time. Threads safe does not mean that one object could be used from
OK looks like I misunderstood the scenario - let me play it back: > > I get a Call from pool from thread t1. Since it is not > exists, pool create > > it, t1 use it, creating a DocumentBuilder, return to pool > > I get a Call from pool from thread 2. Since we have an > instance of Call in > > pool, it will be reused. The operation is not finished yet > in the thread > > t2. > > I get a Call from pool from thread t1. Since it is not > exists, pool create > > it, again from t1, since DocumentBuilder for t1 exists, it > will be reused > > in new Call. Here's the setup: Thread t1, t2; PoolOfCalls pool = new PoolOfCalls (); Thread t1 runs the following code and completes it: Call c = pool.getCall (); // gets call object c1 c.<xyz> (...); pool.releaseCall (c); Now comes thread t2 and it does the following: Call c = pool.getCall (); // again gets call object c1 c.<xyz> (...); // still running stuff Now thread t1 comes back with the following: Call c = pool.getCall (); // get a new call object c2 // however, because the doc builder is associated with the // thread t1, it will be reused I think everything will work just fine in this scenario!! Did I miss something? > different threads at all - just not in the same time. However once you add > DocumentBuilder to the thread local storage or map by threads, you make the > Call and other objects which store DocBuilder in the local variable, tied to > one thread, which makes it not thread safe. I disagree- anything that's in the local state of a thread object is automatically thread safe because by definition because precisely that one thread can access the data. > Please look to the patch I have proposed yesterday > > http://marc.theaimsgroup.com/?l=soap-dev&m=103590623610152&w=2 > > I believe this solution will be better, since it allow reduce number of > DocBuilders created regardless of the user's calls. In multithread > environment it could even use less DocumentBuilder that number of threads. > Note that if you agree and submit it patch, several other classes needs to > be changed, to use pool from all places. Note also that Scott changed class > XMLParserUtil already I did look at it and it looks fine. I still don't see what's wrong with my solution .. that's why I'm being a PITA about not using yours ;-). Let's talk thru this and then settle on the best approach. > Please also look at the proposed patch > http://marc.theaimsgroup.com/?l=soap-dev&m=103582860631002&w=2, were I > extend you idea of replacing write of concatenations with a set of writes Yep, saw that. Will commit that today. Thanks. Sanjiva. -- To unsubscribe, e-mail: <mailto:soap-dev-unsubscribe@;xml.apache.org> For additional commands, e-mail: <mailto:soap-dev-help@;xml.apache.org>