Tom Tromey writes:
 > >>>>> "Andrew" == Andrew Haley <[EMAIL PROTECTED]> writes:
 > 
 > Andrew> What happens is that one thread does ClassLoader.loadClass, which is
 > Andrew> synchronized on the loader, and then URLClassLoader calls toString(),
 > Andrew> which is synchronized on urlloaders.
 > 
 > Another choice would be to simply synchronize on the loader and never
 > synchronize on urlloaders.  There doesn't seem to be a particular
 > advantage to having two different locks here.

Like this?

2005-09-08  Andrew Haley  <[EMAIL PROTECTED]>

        * java/net/URLClassLoader.java (addURLImpl): Synchronize on the
        loader.
        (toString): Likewise.

Index: URLClassLoader.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/net/URLClassLoader.java,v
retrieving revision 1.31
diff -c -2 -p -r1.31 URLClassLoader.java
*** URLClassLoader.java 30 Jun 2005 03:20:02 -0000      1.31
--- URLClassLoader.java 8 Sep 2005 13:32:58 -0000
*************** public class URLClassLoader extends Secu
*** 881,885 ****
    private void addURLImpl(URL newUrl)
    {
!     synchronized (urlloaders)
        {
          if (newUrl == null)
--- 881,885 ----
    private void addURLImpl(URL newUrl)
    {
!     synchronized (this)
        {
          if (newUrl == null)
*************** public class URLClassLoader extends Secu
*** 1112,1116 ****
    public String toString()
    {
!     synchronized (urlloaders)
        {
        if (thisString == null)
--- 1112,1116 ----
    public String toString()
    {
!     synchronized (this)
        {
        if (thisString == null)

Andrew.


_______________________________________________
Classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to