mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
extracted method "runUnderThreadName"
This commit is contained in:
@@ -186,4 +186,15 @@ public class ConcurrencyUtil {
|
||||
public static void joinAll(@NotNull Thread... threads) throws RuntimeException {
|
||||
joinAll(Arrays.asList(threads));
|
||||
}
|
||||
|
||||
public static void runUnderThreadName(@NotNull String name, @NotNull Runnable runnable) {
|
||||
String oldThreadName = Thread.currentThread().getName();
|
||||
Thread.currentThread().setName(name);
|
||||
try {
|
||||
runnable.run();
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setName(oldThreadName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.intellij.util.io;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ConcurrencyUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
@@ -55,15 +56,16 @@ public abstract class BaseDataReader {
|
||||
myFinishedFuture = executeOnPooledThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String oldThreadName = Thread.currentThread().getName();
|
||||
if (!StringUtil.isEmptyOrSpaces(presentableName)) {
|
||||
Thread.currentThread().setName("BaseDataReader: " + presentableName);
|
||||
}
|
||||
try {
|
||||
if (StringUtil.isEmptyOrSpaces(presentableName)) {
|
||||
doRun();
|
||||
}
|
||||
finally {
|
||||
Thread.currentThread().setName(oldThreadName);
|
||||
else {
|
||||
ConcurrencyUtil.runUnderThreadName("BaseDataReader: " + presentableName, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
doRun();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user