diff --git a/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java b/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java index 74c7c4d2ce2..917378389a4 100644 --- a/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java +++ b/src/java.desktop/share/classes/sun/awt/image/ImageFetcher.java @@ -26,7 +26,6 @@ package sun.awt.image; import java.util.Vector; -import sun.awt.AppContext; /** * An ImageFetcher is a thread used to fetch ImageFetchable objects. @@ -34,10 +33,6 @@ import sun.awt.AppContext; * thread may also be used to animate it if necessary, via the * startingAnimation() / stoppingAnimation() methods. * - * There can be up to FetcherInfo.MAX_NUM_FETCHERS_PER_APPCONTEXT - * ImageFetcher threads for each AppContext. A per-AppContext queue - * of ImageFetchables is used to track objects to fetch. - * * @author Jim Graham * @author Fred Ecks */ @@ -153,7 +148,6 @@ class ImageFetcher extends Thread { info.numWaiting++; info.waitList.wait(end - now); } catch (InterruptedException e) { - // A normal occurrence as an AppContext is disposed return null; } finally { info.numWaiting--; @@ -280,28 +274,20 @@ class ImageFetcher extends Thread { // We need to instantiate a new ImageFetcher thread. // First, figure out which ThreadGroup we'll put the // new ImageFetcher into - final AppContext appContext = AppContext.getAppContext(); - ThreadGroup threadGroup = appContext.getThreadGroup(); - ThreadGroup fetcherThreadGroup; - if (threadGroup.getParent() != null) { - // threadGroup is not the root, so we proceed - fetcherThreadGroup = threadGroup; - } else { - // threadGroup is the root ("system") ThreadGroup. - // We instead want to use its child: the "main" - // ThreadGroup. Thus, we start with the current - // ThreadGroup, and go up the tree until - // threadGroup.getParent().getParent() == null. - threadGroup = Thread.currentThread().getThreadGroup(); - ThreadGroup parent = threadGroup.getParent(); - while ((parent != null) - && (parent.getParent() != null)) { - threadGroup = parent; - parent = threadGroup.getParent(); - } - fetcherThreadGroup = threadGroup; + // We don't want the root ("system") ThreadGroup. + // We instead want to use its child: the "main" + // ThreadGroup. Thus, we start with the current + // ThreadGroup, and go up the tree until + // threadGroup.getParent().getParent() == null. + ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); + ThreadGroup parent = threadGroup.getParent(); + while ((parent != null) + && (parent.getParent() != null)) { + threadGroup = parent; + parent = threadGroup.getParent(); } - final ThreadGroup fetcherGroup = fetcherThreadGroup; + final ThreadGroup fetcherGroup = threadGroup; + for (int i = 0; i < info.fetchers.length; i++) { if (info.fetchers[i] == null) { @@ -320,12 +306,13 @@ class ImageFetcher extends Thread { } /** - * The FetcherInfo class encapsulates the per-AppContext ImageFetcher + * The FetcherInfo class encapsulates the ImageFetcher * information. This includes the array of ImageFetchers, as well as * the queue of ImageFetchable objects. */ class FetcherInfo { - static final int MAX_NUM_FETCHERS_PER_APPCONTEXT = 4; + static final int MAX_NUM_FETCHERS = 4; + static final FetcherInfo FETCHER_INFO = new FetcherInfo(); Thread[] fetchers; int numFetchers; @@ -333,25 +320,13 @@ class FetcherInfo { Vector waitList; private FetcherInfo() { - fetchers = new Thread[MAX_NUM_FETCHERS_PER_APPCONTEXT]; + fetchers = new Thread[MAX_NUM_FETCHERS]; numFetchers = 0; numWaiting = 0; waitList = new Vector<>(); } - /* The key to put()/get() the FetcherInfo into/from the AppContext. */ - private static final Object FETCHER_INFO_KEY = - new StringBuffer("FetcherInfo"); - static FetcherInfo getFetcherInfo() { - AppContext appContext = AppContext.getAppContext(); - synchronized(appContext) { - FetcherInfo info = (FetcherInfo)appContext.get(FETCHER_INFO_KEY); - if (info == null) { - info = new FetcherInfo(); - appContext.put(FETCHER_INFO_KEY, info); - } - return info; - } + return FETCHER_INFO; } }