#142: Improve thread names support.

Contributed by @KirillTim
This commit is contained in:
Andrey Pangin
2019-01-05 01:21:30 +03:00
parent a2c70c99ba
commit 02dc90587b
16 changed files with 311 additions and 178 deletions
+33
View File
@@ -0,0 +1,33 @@
public class ThreadsTarget {
public static void main(String[] args) {
new Thread(new Runnable() {
@Override
public void run() {
methodForThreadEarlyEnd();
}
}, "ThreadEarlyEnd").start();
new Thread(new Runnable() {
@Override
public void run() {
Thread.currentThread().setName("RenamedThread");
methodForRenamedThread();
}
}, "ThreadWillBeRenamed").start();
}
static void methodForThreadEarlyEnd() {
long now = System.currentTimeMillis();
long counter = 0;
while (System.currentTimeMillis() - now < 300) {
counter++;
}
}
static void methodForRenamedThread() {
long now = System.currentTimeMillis();
long counter = 0;
while (System.currentTimeMillis() - now < 1000) {
counter++;
}
}
}