mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-26 06:14:49 +02:00
8345432: (ch, fs) Replace anonymous Thread with InnocuousThread
Reviewed-by: alanb
This commit is contained in:
parent
9c393a243d
commit
d723597dd9
5 changed files with 13 additions and 14 deletions
|
@ -70,7 +70,7 @@ public class ThreadPool {
|
|||
|
||||
static ThreadFactory defaultThreadFactory() {
|
||||
return (Runnable r) -> {
|
||||
Thread t = new Thread(r);
|
||||
Thread t = InnocuousThread.newThread(r);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
};
|
||||
|
|
|
@ -25,9 +25,10 @@
|
|||
|
||||
package sun.nio.fs;
|
||||
|
||||
import java.nio.file.*;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.*;
|
||||
import java.util.*;
|
||||
import jdk.internal.misc.InnocuousThread;
|
||||
|
||||
/**
|
||||
* Base implementation of background poller thread used in watch service
|
||||
|
@ -53,11 +54,7 @@ abstract class AbstractPoller implements Runnable {
|
|||
* Starts the poller thread
|
||||
*/
|
||||
public void start() {
|
||||
Thread thr = new Thread(null,
|
||||
this,
|
||||
"FileSystemWatchService",
|
||||
0,
|
||||
false);
|
||||
Thread thr = InnocuousThread.newThread("FileSystemWatchService", this);
|
||||
thr.setDaemon(true);
|
||||
thr.start();
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -25,14 +25,15 @@
|
|||
|
||||
package sun.nio.fs;
|
||||
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import jdk.internal.misc.InnocuousThread;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
|
||||
/**
|
||||
* Base implementation of a task (typically native) that polls a memory location
|
||||
* during execution so that it may be aborted/cancelled before completion. The
|
||||
* task is executed by invoking the {@link runInterruptibly} method defined
|
||||
* here and cancelled by invoking Thread.interrupt.
|
||||
* task is executed by invoking the {@linkplain #runInterruptibly} method
|
||||
* defined here and cancelled by invoking Thread.interrupt.
|
||||
*/
|
||||
|
||||
abstract class Cancellable implements Runnable {
|
||||
|
@ -117,7 +118,7 @@ abstract class Cancellable implements Runnable {
|
|||
* thread by writing into the memory location that it polls cooperatively.
|
||||
*/
|
||||
static void runInterruptibly(Cancellable task) throws ExecutionException {
|
||||
Thread t = new Thread(null, task, "NIO-Task", 0, false);
|
||||
Thread t = InnocuousThread.newThread("CancellableOp", task);
|
||||
t.start();
|
||||
boolean cancelledByInterrupt = false;
|
||||
while (t.isAlive()) {
|
||||
|
|
|
@ -47,6 +47,7 @@ import java.util.concurrent.ScheduledExecutorService;
|
|||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import jdk.internal.misc.InnocuousThread;
|
||||
import static java.nio.file.LinkOption.NOFOLLOW_LINKS;
|
||||
|
||||
/**
|
||||
|
@ -73,7 +74,7 @@ class PollingWatchService
|
|||
.newSingleThreadScheduledExecutor(new ThreadFactory() {
|
||||
@Override
|
||||
public Thread newThread(Runnable r) {
|
||||
Thread t = new Thread(null, r, "FileSystemWatcher", 0, false);
|
||||
Thread t = InnocuousThread.newThread("FileSystemWatcher", r);
|
||||
t.setDaemon(true);
|
||||
return t;
|
||||
}});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue