I've been experimenting with some new IoC/DI ideas for Tapestry 5.

In the quest for perfection, I've noticed that there is the potential
for thread deadlock. The scenario is a little hard to explain, but is
based on two or more threads trying to instantiate related services
simultaneously.

To limit the possiblility of this, I'm using a simple synchronized
block (i.e., a per-module mutex) whenever first obtaining a service
proxy within a module. I'm considering moving this up to a global
mutex on all service construction.

Another possibility would be to have a single thread responsible for
all of this. When an arbitrary thread requests a service that doesn't
yet exist (even as a proxy), it would message this service building
thread to do the work. This would ensure no possibility of deadlock
without the kind of lock contention a global mutex would require.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Jakarta HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Reply via email to