[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Deadlock in java.net.URLClassLoader
From: |
Andrew Haley |
Subject: |
Re: Deadlock in java.net.URLClassLoader |
Date: |
Thu, 8 Sep 2005 14:35:53 +0100 |
Tom Tromey writes:
> >>>>> "Andrew" == Andrew Haley <address@hidden> 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 <address@hidden>
* 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.