8147544: Remove sun.misc.ManagedLocalsThread from java.desktop

Reviewed-by: serb, chegar
This commit is contained in:
Phil Race 2016-04-04 14:22:07 -07:00
parent ed6f748110
commit 01b34486fa
47 changed files with 125 additions and 141 deletions

View File

@ -35,7 +35,6 @@ import javax.swing.event.ListDataEvent;
import javax.swing.filechooser.FileSystemView;
import javax.swing.table.AbstractTableModel;
import sun.misc.ManagedLocalsThread;
/**
* NavServices-like implementation of a file Table
*
@ -393,7 +392,7 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
this.currentDirectory = currentDirectory;
this.fid = fid;
String name = "Aqua L&F File Loading Thread";
this.loadThread = new ManagedLocalsThread(this, name);
this.loadThread = new Thread(null, this, name, 0, false);
this.loadThread.start();
}

View File

@ -42,7 +42,6 @@ import sun.awt.FontConfiguration;
import sun.awt.HeadlessToolkit;
import sun.awt.util.ThreadGroupUtils;
import sun.lwawt.macosx.*;
import sun.misc.ManagedLocalsThread;
public final class CFontManager extends SunFontManager {
private static Hashtable<String, Font2D> genericFonts = new Hashtable<String, Font2D>();

View File

@ -35,7 +35,6 @@ import java.security.*;
import java.util.*;
import sun.awt.*;
import sun.misc.ManagedLocalsThread;
import sun.print.*;
import sun.awt.util.ThreadGroupUtils;
@ -77,13 +76,14 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
shutdown();
waitForRunState(STATE_CLEANUP);
};
Thread shutdown = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
Thread shutdown = new Thread(
ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable,
"AWT-Shutdown", 0, false);
shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown);
String name = "AWT-LW";
Thread toolkitThread = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), this, name);
Thread toolkitThread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
toolkitThread.setDaemon(true);
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
toolkitThread.start();

View File

@ -44,7 +44,6 @@ import sun.awt.dnd.*;
import sun.lwawt.LWComponentPeer;
import sun.lwawt.LWWindowPeer;
import sun.lwawt.PlatformWindow;
import sun.misc.ManagedLocalsThread;
public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
@ -181,7 +180,7 @@ public final class CDragSourceContextPeer extends SunDragSourceContextPeer {
}
}
};
new ManagedLocalsThread(dragRunnable).start();
new Thread(null, dragRunnable, "Drag", 0, false).start();
} catch (Exception e) {
final long nativeDragSource = getNativeContext();
setNativeContext(0);

View File

@ -37,7 +37,6 @@ import java.io.*;
import sun.awt.CausedFocusEvent.Cause;
import sun.awt.AWTAccessor;
import sun.java2d.pipe.Region;
import sun.misc.ManagedLocalsThread;
import sun.security.action.GetBooleanAction;
class CFileDialog implements FileDialogPeer {
@ -120,7 +119,7 @@ class CFileDialog implements FileDialogPeer {
if (visible) {
// Java2 Dialog class requires peer to run code in a separate thread
// and handles keeping the call modal
new ManagedLocalsThread(new Task()).start();
new Thread(null, new Task(), "FileDialog", 0, false).start();
}
// We hide ourself before "show" returns - setVisible(false)
// doesn't apply

View File

@ -29,7 +29,6 @@ import java.awt.*;
import java.awt.dnd.*;
import sun.lwawt.*;
import sun.misc.ManagedLocalsThread;
public class CPrinterDialogPeer extends LWWindowPeer {
static {
@ -59,7 +58,7 @@ public class CPrinterDialogPeer extends LWWindowPeer {
printerDialog.setRetVal(printerDialog.showDialog());
printerDialog.setVisible(false);
};
new ManagedLocalsThread(task).start();
new Thread(null, task, "PrintDialog", 0, false).start();
}
}

View File

@ -44,7 +44,6 @@ import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.PageRanges;
import sun.java2d.*;
import sun.misc.ManagedLocalsThread;
import sun.print.*;
public final class CPrinterJob extends RasterPrinterJob {
@ -775,7 +774,8 @@ public final class CPrinterJob extends RasterPrinterJob {
// upcall from native
private static void detachPrintLoop(final long target, final long arg) {
new ManagedLocalsThread(() -> _safePrintLoop(target, arg)).start();
new Thread(null, () -> _safePrintLoop(target, arg),
"PrintLoop", 0, false).start();
}
private static native void _safePrintLoop(long target, long arg);

View File

@ -26,7 +26,6 @@
package com.sun.imageio.stream;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
import java.io.IOException;
import java.security.AccessController;
@ -92,8 +91,8 @@ public class StreamCloser {
* Make its parent the top-level thread group.
*/
ThreadGroup tg = ThreadGroupUtils.getRootThreadGroup();
streamCloser = new ManagedLocalsThread(tg,
streamCloserRunnable);
streamCloser = new Thread(tg, streamCloserRunnable,
"StreamCloser", 0, false);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/

View File

@ -64,7 +64,6 @@ import sun.awt.SunToolkit;
import sun.awt.OSInfo;
import sun.awt.shell.ShellFolder;
import sun.font.FontUtilities;
import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction;
import sun.swing.DefaultLayoutStyle;
@ -2053,7 +2052,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
if (audioRunnable != null) {
// Runnable appears to block until completed playing, hence
// start up another thread to handle playing.
new ManagedLocalsThread(audioRunnable).start();
new Thread(null, audioRunnable, "Audio", 0, false).start();
}
}
}

View File

@ -25,8 +25,6 @@
package com.sun.media.sound;
import sun.misc.ManagedLocalsThread;
import java.io.BufferedInputStream;
import java.io.InputStream;
import java.io.File;
@ -145,12 +143,11 @@ final class JSSecurityManager {
static Thread createThread(final Runnable runnable,
final String threadName,
final boolean isDaemon, final int priority,
final boolean doStart) {
Thread thread = new ManagedLocalsThread(runnable);
final boolean doStart)
{
String name = (threadName != null) ? threadName : "JSSM Thread";
Thread thread = new Thread(null, runnable, threadName, 0, false);
if (threadName != null) {
thread.setName(threadName);
}
thread.setDaemon(isDaemon);
if (priority >= 0) {
thread.setPriority(priority);

View File

@ -24,8 +24,6 @@
*/
package com.sun.media.sound;
import sun.misc.ManagedLocalsThread;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
@ -55,7 +53,7 @@ public final class SoftAudioPusher implements Runnable {
if (active)
return;
active = true;
audiothread = new ManagedLocalsThread(this);
audiothread = new Thread(null, this, "AudioPusher", 0, false);
audiothread.setDaemon(true);
audiothread.setPriority(Thread.MAX_PRIORITY);
audiothread.start();

View File

@ -24,8 +24,6 @@
*/
package com.sun.media.sound;
import sun.misc.ManagedLocalsThread;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import java.io.EOFException;
@ -216,7 +214,7 @@ public final class SoftJitterCorrector extends AudioInputStream {
}
};
thread = new ManagedLocalsThread(runnable);
thread = new Thread(null, runnable, "JitterCorrector", 0, false);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();

View File

@ -25,8 +25,6 @@
package com.sun.media.sound;
import sun.misc.ManagedLocalsThread;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
@ -141,7 +139,7 @@ public final class SoftSynthesizer implements AudioSynthesizer,
pusher = null;
jitter_stream = null;
sourceDataLine = null;
new ManagedLocalsThread(runnable).start();
new Thread(null, runnable, "Synthesizer",0,false).start();
}
return len;
}

View File

@ -31,7 +31,6 @@ import java.awt.event.WindowEvent;
import java.util.ArrayList;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
import sun.awt.dnd.SunDragSourceContextPeer;
@ -55,7 +54,7 @@ import sun.awt.dnd.SunDragSourceContextPeer;
*
* @since 1.1
*/
class EventDispatchThread extends ManagedLocalsThread {
class EventDispatchThread extends Thread {
private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
@ -66,8 +65,16 @@ class EventDispatchThread extends ManagedLocalsThread {
private ArrayList<EventFilter> eventFilters = new ArrayList<EventFilter>();
/**
* Must always call 5 args super-class constructor passing false
* to indicate not to inherit locals.
*/
private EventDispatchThread() {
throw new UnsupportedOperationException("Must erase locals");
}
EventDispatchThread(ThreadGroup group, String name, EventQueue queue) {
super(group, name);
super(group, null, name, 0, false);
setEventQueue(queue);
}

View File

@ -35,8 +35,6 @@
package java.awt.image.renderable;
import sun.misc.ManagedLocalsThread;
import java.awt.image.ColorModel;
import java.awt.image.DataBuffer;
import java.awt.image.ImageConsumer;
@ -137,7 +135,7 @@ public class RenderableImageProducer implements ImageProducer, Runnable {
addConsumer(ic);
// Need to build a runnable object for the Thread.
String name = "RenderableImageProducer Thread";
Thread thread = new ManagedLocalsThread(this, name);
Thread thread = new Thread(null, this, name, 0, false);
thread.start();
}

View File

@ -56,7 +56,6 @@ import java.util.List;
import javax.print.attribute.*;
import javax.print.PrintService;
import sun.misc.ManagedLocalsThread;
import sun.reflect.misc.ReflectUtil;
import sun.swing.SwingUtilities2;
@ -6375,7 +6374,7 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
};
// start printing on another thread
Thread th = new ManagedLocalsThread(runnable);
Thread th = new Thread(null, runnable, "JTablePrint", 0, false);
th.start();
printingStatus.showModal(true);

View File

@ -36,7 +36,6 @@ import java.util.concurrent.*;
import java.util.concurrent.locks.*;
import java.util.concurrent.atomic.AtomicLong;
import sun.awt.AppContext;
import sun.misc.ManagedLocalsThread;
/**
* Internal class to manage all Timers using one thread.
@ -101,8 +100,8 @@ class TimerQueue implements Runnable
final ThreadGroup threadGroup = AppContext.getAppContext().getThreadGroup();
AccessController.doPrivileged((PrivilegedAction<Object>) () -> {
String name = "TimerQueue";
Thread timerThread = new ManagedLocalsThread(threadGroup,
this, name);
Thread timerThread =
new Thread(threadGroup, this, name, 0, false);
timerThread.setDaemon(true);
timerThread.setPriority(Thread.NORM_PRIORITY);
timerThread.start();

View File

@ -26,7 +26,6 @@
package javax.swing.plaf.basic;
import sun.awt.shell.ShellFolder;
import sun.misc.ManagedLocalsThread;
import javax.swing.*;
import javax.swing.event.ListDataEvent;
@ -271,7 +270,7 @@ public class BasicDirectoryModel extends AbstractListModel<Object> implements Pr
this.currentDirectory = currentDirectory;
this.fid = fid;
String name = "Basic L&F File Loading Thread";
this.loadThread = new ManagedLocalsThread(this, name);
this.loadThread = new Thread(null, this, name, 0, false);
this.loadThread.start();
}

View File

@ -70,7 +70,6 @@ import javax.print.attribute.*;
import sun.awt.AppContext;
import sun.misc.ManagedLocalsThread;
import sun.swing.PrintingStatus;
import sun.swing.SwingUtilities2;
import sun.swing.text.TextComponentPrintable;
@ -2353,7 +2352,8 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
runnablePrinting.run();
} else {
if (isEventDispatchThread) {
new ManagedLocalsThread(runnablePrinting).start();
new Thread(null, runnablePrinting,
"JTextComponentPrint", 0, false ).start();
printingStatus.showModal(true);
} else {
printingStatus.showModal(false);

View File

@ -26,7 +26,6 @@ package javax.swing.text;
import java.util.Vector;
import sun.awt.AppContext;
import sun.misc.ManagedLocalsThread;
/**
* A queue of text layout tasks.
@ -92,7 +91,7 @@ public class LayoutQueue {
}
} while (work != null);
};
worker = new ManagedLocalsThread(workerRunnable, "text-layout");
worker = new Thread(null, workerRunnable, "text-layout", 0, false);
worker.setPriority(Thread.MIN_PRIORITY);
worker.start();
}

View File

@ -52,7 +52,6 @@ import java.security.Permission;
import java.security.PermissionCollection;
import sun.awt.AppContext;
import sun.awt.SunToolkit;
import sun.misc.ManagedLocalsThread;
import sun.net.www.ParseUtil;
import sun.security.util.SecurityConstants;
@ -858,13 +857,20 @@ public void grab() {
* this operation to complete before continuing, wait for the notifyAll()
* operation on the syncObject to occur.
*/
class AppContextCreator extends ManagedLocalsThread {
class AppContextCreator extends Thread {
Object syncObject = new Object();
AppContext appContext = null;
volatile boolean created = false;
/**
* Must call the 5-args super-class constructor to erase locals.
*/
private AppContextCreator() {
throw new UnsupportedOperationException("Must erase locals");
}
AppContextCreator(ThreadGroup group) {
super(group, "AppContextCreator");
super(group, null, "AppContextCreator", 0, false);
}
public void run() {

View File

@ -44,7 +44,6 @@ import sun.awt.AppContext;
import sun.awt.EmbeddedFrame;
import sun.awt.SunToolkit;
import sun.awt.util.PerformanceLogger;
import sun.misc.ManagedLocalsThread;
import sun.security.util.SecurityConstants;
/**
@ -166,7 +165,7 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
ThreadGroup appletGroup = loader.getThreadGroup();
handler = new ManagedLocalsThread(appletGroup, this, "thread " + nm);
handler = new Thread(appletGroup, this, "thread " + nm, 0, false);
// set the context class loader for this thread
AccessController.doPrivileged(new PrivilegedAction<Object>() {
@Override
@ -396,9 +395,8 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable {
// until the loader thread terminates.
// (one way or another).
if (loaderThread == null) {
// REMIND: do we want a name?
//System.out.println("------------------- loading applet");
setLoaderThread(new ManagedLocalsThread(this));
setLoaderThread(new Thread(null, this,
"AppletLoader", 0, false));
loaderThread.start();
// we get to go to sleep while this runs
loaderThread.join();

View File

@ -38,7 +38,6 @@ import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.awt.SunToolkit;
import sun.awt.AppContext;
import sun.misc.ManagedLocalsThread;
/**
* A frame to show the applet tag in.
@ -854,7 +853,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
//
final AppletPanel p = panel;
new ManagedLocalsThread(new Runnable()
new Thread(null, new Runnable()
{
@Override
public void run()
@ -867,7 +866,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
appletSystemExit();
}
}
}).start();
},
"AppletCloser", 0, false).start();
}
/**
@ -890,7 +890,7 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
// spawn a new thread to avoid blocking the event queue
// when calling appletShutdown.
//
new ManagedLocalsThread(new Runnable()
new Thread(null, new Runnable()
{
@Override
public void run()
@ -901,7 +901,8 @@ public class AppletViewer extends Frame implements AppletContext, Printable {
}
appletSystemExit();
}
}).start();
},
"AppletQuit", 0, false).start();
}
/**

View File

@ -34,7 +34,6 @@ import java.util.Map;
import java.util.Set;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@ -337,8 +336,8 @@ public final class AWTAutoShutdown implements Runnable {
private void activateBlockerThread() {
AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "AWT-Shutdown";
Thread thread = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), this, name);
Thread thread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), this, name, 0, false);
thread.setContextClassLoader(null);
thread.setDaemon(false);
blockerThread = thread;

View File

@ -46,7 +46,6 @@ import java.lang.ref.SoftReference;
import jdk.internal.misc.JavaAWTAccess;
import jdk.internal.misc.SharedSecrets;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
@ -598,8 +597,8 @@ public final class AppContext {
}
public Thread run() {
Thread t = new ManagedLocalsThread(appContext.getThreadGroup(),
runnable, "AppContext Disposer");
Thread t = new Thread(appContext.getThreadGroup(),
runnable, "AppContext Disposer", 0, false);
t.setContextClassLoader(appContext.getContextClassLoader());
t.setPriority(Thread.NORM_PRIORITY + 1);
t.setDaemon(true);

View File

@ -55,7 +55,6 @@ import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;
import sun.awt.InputMethodSupport;
import sun.awt.SunToolkit;
import sun.misc.ManagedLocalsThread;
/**
* {@code InputMethodManager} is an abstract class that manages the input
@ -166,7 +165,8 @@ public abstract class InputMethodManager {
// to choose from. Otherwise, just keep the instance.
if (imm.hasMultipleInputMethods()) {
imm.initialize();
Thread immThread = new ManagedLocalsThread(imm, threadName);
Thread immThread =
new Thread(null, imm, threadName, 0, false);
immThread.setDaemon(true);
immThread.setPriority(Thread.NORM_PRIORITY + 1);
immThread.start();

View File

@ -27,7 +27,6 @@ package sun.awt.image;
import java.util.Vector;
import sun.awt.AppContext;
import sun.misc.ManagedLocalsThread;
/**
* An ImageFetcher is a thread used to fetch ImageFetchable objects.
@ -42,7 +41,7 @@ import sun.misc.ManagedLocalsThread;
* @author Jim Graham
* @author Fred Ecks
*/
class ImageFetcher extends ManagedLocalsThread {
class ImageFetcher extends Thread {
static final int HIGH_PRIORITY = 8;
static final int LOW_PRIORITY = 3;
static final int ANIM_PRIORITY = 2;
@ -51,11 +50,18 @@ class ImageFetcher extends ManagedLocalsThread {
// ImageFetchable to be added to the
// queue before an ImageFetcher dies
/**
* We must only call the 5 args super() constructor passing
* in "false" to indicate to not inherit locals.
*/
private ImageFetcher() {
throw new UnsupportedOperationException("Must erase locals");
}
/**
* Constructor for ImageFetcher -- only called by add() below.
*/
private ImageFetcher(ThreadGroup threadGroup, int index) {
super(threadGroup, "Image Fetcher " + index);
super(threadGroup, null, "Image Fetcher " + index, 0, false);
setDaemon(true);
}

View File

@ -36,7 +36,6 @@ import java.util.concurrent.TimeUnit;
import sun.awt.AppContext;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
public class CreatedFontTracker {
@ -122,8 +121,8 @@ public class CreatedFontTracker {
* Make its parent the top-level thread group.
*/
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
t = new ManagedLocalsThread(rootTG,
TempFileDeletionHook::runHooks);
t = new Thread(rootTG, TempFileDeletionHook::runHooks,
"TempFontFileDeleter", 0, false);
/* Set context class loader to null in order to avoid
* keeping a strong reference to an application classloader.
*/

View File

@ -55,7 +55,6 @@ import sun.awt.FontConfiguration;
import sun.awt.SunToolkit;
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.FontSupport;
import sun.misc.ManagedLocalsThread;
import sun.util.logging.PlatformLogger;
/**
@ -2513,8 +2512,8 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
};
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
fileCloser = new ManagedLocalsThread(rootTG,
fileCloserRunnable);
fileCloser = new Thread(rootTG, fileCloserRunnable,
"FileCloser", 0, false);
fileCloser.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(fileCloser);
return null;

View File

@ -26,7 +26,6 @@
package sun.java2d;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
import java.lang.ref.Reference;
import java.lang.ref.ReferenceQueue;
@ -85,7 +84,7 @@ public class Disposer implements Runnable {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
String name = "Java2D Disposer";
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
Thread t = new ManagedLocalsThread(rootTG, disposerInstance, name);
Thread t = new Thread(rootTG, disposerInstance, name, 0, false);
t.setContextClassLoader(null);
t.setDaemon(true);
t.setPriority(Thread.MAX_PRIORITY);

View File

@ -48,7 +48,6 @@ import java.io.FileNotFoundException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import sun.misc.ManagedLocalsThread;
import sun.security.action.GetPropertyAction;
/**
@ -420,8 +419,9 @@ public abstract class GraphicsPrimitive {
public static void setShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
TraceReporter t = new TraceReporter();
Thread thread = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), t);
Thread thread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), t,
"TraceReporter", 0, false);
thread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(thread);
return null;

View File

@ -28,7 +28,6 @@ package sun.java2d.opengl;
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.pipe.RenderBuffer;
import sun.java2d.pipe.RenderQueue;
import sun.misc.ManagedLocalsThread;
import static sun.java2d.pipe.BufferedOpCodes.*;
import java.security.AccessController;
@ -161,7 +160,8 @@ public class OGLRenderQueue extends RenderQueue {
public QueueFlusher() {
String name = "Java2D Queue Flusher";
thread = new ManagedLocalsThread(ThreadGroupUtils.getRootThreadGroup(), this, name);
thread = new Thread(ThreadGroupUtils.getRootThreadGroup(),
this, name, 0, false);
thread.setDaemon(true);
thread.setPriority(Thread.MAX_PRIORITY);
thread.start();

View File

@ -71,7 +71,6 @@ import javax.print.attribute.standard.OrientationRequested;
import javax.print.attribute.standard.MediaSizeName;
import javax.print.attribute.standard.PageRanges;
import sun.misc.ManagedLocalsThread;
import sun.print.SunPageSelection;
import sun.print.SunMinMaxPage;
@ -1009,7 +1008,8 @@ public class PrintJob2D extends PrintJob implements Printable, Runnable {
}
private void startPrinterJobThread() {
printerJobThread = new ManagedLocalsThread(this, "printerJobThread");
printerJobThread =
new Thread(null, this, "printerJobThread", 0, false);
printerJobThread.start();
}

View File

@ -25,8 +25,6 @@
package sun.print;
import sun.misc.ManagedLocalsThread;
import java.util.Vector;
import javax.print.PrintService;
@ -42,15 +40,19 @@ import javax.print.event.PrintServiceAttributeListener;
* to obtain the state of the attributes and notifies the listeners of
* any changes.
*/
class ServiceNotifier extends ManagedLocalsThread {
class ServiceNotifier extends Thread {
private PrintService service;
private Vector<PrintServiceAttributeListener> listeners;
private boolean stop = false;
private PrintServiceAttributeSet lastSet;
/*
* If adding any other constructors, always call the 5-args
* super-class constructor passing "false" for inherit-locals.
*/
ServiceNotifier(PrintService service) {
super(service.getName() + " notifier");
super(null, null, service.getName() + " notifier", 0, false);
this.service = service;
listeners = new Vector<>();
try {
@ -70,7 +72,7 @@ class ServiceNotifier extends ManagedLocalsThread {
}
}
void removeListener(PrintServiceAttributeListener listener) {
void removeListener(PrintServiceAttributeListener listener) {
synchronized (this) {
if (listener == null || listeners == null) {
return;

View File

@ -29,7 +29,6 @@ import java.awt.peer.FileDialogPeer;
import java.io.File;
import java.io.FilenameFilter;
import sun.awt.AWTAccessor;
import sun.misc.ManagedLocalsThread;
/**
* FileDialogPeer for the GtkFileChooser.
@ -120,7 +119,7 @@ final class GtkFileDialogPeer extends XDialogPeer implements FileDialogPeer {
standaloneWindow = 0;
fd.setVisible(false);
};
new ManagedLocalsThread(task).start();
new Thread(null, task, "ShowDialog", 0, false).start();
} else {
quit();
fd.setVisible(false);

View File

@ -29,7 +29,6 @@ import java.awt.*;
import java.awt.event.*;
import java.awt.peer.TrayIconPeer;
import sun.awt.*;
import sun.misc.ManagedLocalsThread;
import java.awt.image.*;
import java.text.BreakIterator;
@ -452,7 +451,7 @@ public abstract class InfoWindow extends Window {
final Thread thread;
Displayer() {
this.thread = new ManagedLocalsThread(this);
this.thread = new Thread(null, this, "Displayer", 0, false);
this.thread.setDaemon(true);
}

View File

@ -29,7 +29,6 @@ import java.awt.PopupMenu;
import java.awt.Taskbar.Feature;
import java.awt.peer.TaskbarPeer;
import java.awt.event.ActionEvent;
import sun.misc.ManagedLocalsThread;
import java.security.AccessController;
import sun.security.action.GetPropertyAction;
@ -48,10 +47,8 @@ final class XTaskbarPeer implements TaskbarPeer {
new GetPropertyAction("java.desktop.appName", ""));
nativeLibraryLoaded = init(dname);
if (nativeLibraryLoaded) {
ManagedLocalsThread t
= new ManagedLocalsThread(() -> {
runloop();
});
Thread t = new Thread(null, () -> { runloop(); },
"TaskBar", 0, false);
t.setDaemon(true);
t.start();
}

View File

@ -284,8 +284,8 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
}
};
String name = "XToolkt-Shutdown-Thread";
Thread shutdownThread = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), r, name);
Thread shutdownThread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
shutdownThread.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdownThread);
return null;
@ -332,8 +332,9 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
toolkitThread = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "AWT-XAWT";
Thread thread = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), this, name);
Thread thread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), this, name,
0, false);
thread.setContextClassLoader(null);
thread.setPriority(Thread.NORM_PRIORITY + 1);
thread.setDaemon(true);

View File

@ -44,7 +44,6 @@ import sun.java2d.loops.SurfaceType;
import sun.awt.util.ThreadGroupUtils;
import sun.java2d.SunGraphicsEnvironment;
import sun.misc.ManagedLocalsThread;
/**
* This is an implementation of a GraphicsDevice object for a single
@ -442,8 +441,8 @@ public final class X11GraphicsDevice extends GraphicsDevice
}
};
String name = "Display-Change-Shutdown-Thread-" + screen;
Thread t = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), r, name);
Thread t = new Thread(
ThreadGroupUtils.getRootThreadGroup(), r, name, 0, false);
t.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(t);
return null;

View File

@ -25,8 +25,6 @@
package sun.print;
import sun.misc.ManagedLocalsThread;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStream;
@ -213,7 +211,8 @@ public class PrintServiceLookupProvider extends PrintServiceLookup
public PrintServiceLookupProvider() {
// start the printer listener thread
if (pollServices) {
Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
Thread thr = new Thread(null, new PrinterChangeListener(),
"PrinterListener", 0, false);
thr.setDaemon(true);
thr.start();
IPPPrintService.debug_println(debugPrefix+"polling turned on");

View File

@ -41,7 +41,6 @@ import java.util.stream.Stream;
import static sun.awt.shell.Win32ShellFolder2.*;
import sun.awt.OSInfo;
import sun.awt.util.ThreadGroupUtils;
import sun.misc.ManagedLocalsThread;
// NOTE: This class supersedes Win32ShellFolderManager, which was removed
// from distribution after version 1.4.2.
@ -524,8 +523,9 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
return null;
});
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
Thread t = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), shutdownHook);
Thread t = new Thread(
ThreadGroupUtils.getRootThreadGroup(), shutdownHook,
"ShellFolder", 0, false);
Runtime.getRuntime().addShutdownHook(t);
return null;
});
@ -548,8 +548,9 @@ final class Win32ShellFolderManager2 extends ShellFolderManager {
* which will not get GCed before VM exit.
* Make its parent the top-level thread group.
*/
Thread thread = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), comRun, name);
Thread thread = new Thread(
ThreadGroupUtils.getRootThreadGroup(), comRun, name,
0, false);
thread.setDaemon(true);
return thread;
});

View File

@ -36,7 +36,6 @@ import java.util.MissingResourceException;
import java.util.Vector;
import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
import sun.misc.ManagedLocalsThread;
final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@ -98,7 +97,7 @@ final class WFileDialogPeer extends WWindowPeer implements FileDialogPeer {
@Override
public void show() {
new ManagedLocalsThread(this::_show).start();
new Thread(null, this::_show, "FileDialog", 0, false).start();
}
@Override

View File

@ -25,8 +25,6 @@
package sun.awt.windows;
import sun.misc.ManagedLocalsThread;
final class WPageDialogPeer extends WPrintDialogPeer {
WPageDialogPeer(WPageDialog target) {
@ -53,6 +51,6 @@ final class WPageDialogPeer extends WPrintDialogPeer {
}
((WPrintDialog)target).setVisible(false);
};
new ManagedLocalsThread(runnable).start();
new Thread(null, runnable, "PageDialog", 0, false).start();
}
}

View File

@ -32,7 +32,6 @@ import java.awt.dnd.DropTarget;
import java.util.Vector;
import sun.awt.CausedFocusEvent;
import sun.awt.AWTAccessor;
import sun.misc.ManagedLocalsThread;
class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
@ -78,7 +77,7 @@ class WPrintDialogPeer extends WWindowPeer implements DialogPeer {
}
((WPrintDialog)target).setVisible(false);
};
new ManagedLocalsThread(runnable).start();
new Thread(null, runnable, "PrintDialog", 0, false).start();
}
synchronized void setHWnd(long hwnd) {

View File

@ -52,7 +52,6 @@ import sun.awt.datatransfer.DataTransferer;
import sun.java2d.d3d.D3DRenderQueue;
import sun.java2d.opengl.OGLRenderQueue;
import sun.misc.ManagedLocalsThread;
import sun.print.PrintJob2D;
import java.awt.dnd.DragSource;
@ -256,7 +255,7 @@ public final class WToolkit extends SunToolkit implements Runnable {
(PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
if (!startToolkitThread(this, rootTG)) {
String name = "AWT-Windows";
Thread toolkitThread = new ManagedLocalsThread(rootTG, this, name);
Thread toolkitThread = new Thread(rootTG, this, name, 0, false);
toolkitThread.setDaemon(true);
toolkitThread.start();
}
@ -283,8 +282,9 @@ public final class WToolkit extends SunToolkit implements Runnable {
private void registerShutdownHook() {
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
Thread shutdown = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), this::shutdown);
Thread shutdown = new Thread(
ThreadGroupUtils.getRootThreadGroup(), this::shutdown,
"ToolkitShutdown", 0, false);
shutdown.setContextClassLoader(null);
Runtime.getRuntime().addShutdownHook(shutdown);
return null;

View File

@ -49,7 +49,6 @@ import sun.java2d.SurfaceData;
import sun.java2d.windows.GDIWindowSurfaceData;
import sun.java2d.d3d.D3DSurfaceData.D3DWindowSurfaceData;
import sun.java2d.windows.WindowsFlags;
import sun.misc.ManagedLocalsThread;
/**
* This class handles rendering to the screen with the D3D pipeline.
@ -99,8 +98,9 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager
done = true;
wakeUpUpdateThread();
};
Thread shutdown = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable);
Thread shutdown = new Thread(
ThreadGroupUtils.getRootThreadGroup(), shutdownRunnable,
"ScreenUpdater", 0, false);
shutdown.setContextClassLoader(null);
try {
Runtime.getRuntime().addShutdownHook(shutdown);
@ -348,8 +348,9 @@ public class D3DScreenUpdateManager extends ScreenUpdateManager
if (screenUpdater == null) {
screenUpdater = AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
String name = "D3D Screen Updater";
Thread t = new ManagedLocalsThread(
ThreadGroupUtils.getRootThreadGroup(), this, name);
Thread t = new Thread(
ThreadGroupUtils.getRootThreadGroup(), this, name,
0, false);
// REMIND: should it be higher?
t.setPriority(Thread.NORM_PRIORITY + 2);
t.setDaemon(true);

View File

@ -25,8 +25,6 @@
package sun.print;
import sun.misc.ManagedLocalsThread;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
@ -99,7 +97,8 @@ public class PrintServiceLookupProvider extends PrintServiceLookup {
return;
}
// start the printer listener thread
Thread thr = new ManagedLocalsThread(new PrinterChangeListener());
Thread thr = new Thread(null, new PrinterChangeListener(),
"PrinterListener", 0, false);
thr.setDaemon(true);
thr.start();
} /* else condition ought to never happen! */