Why thread name was changing for each and every run | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why thread name was changing for each and every run

In my first run thread 1 name was :Thread-36 thread 2 name was:Thread-37 in my 2nd run Thread 1 name was:thread-45 Thread 2name was:thread-46 in my 3rd run thread 1 name was:thread-63 thread 2 name was:thread-64 Please expain Post: https://www.sololearn.com/post/778716/?ref=app

24th Nov 2020, 3:33 AM
VAMSI
VAMSI - avatar
2 Answers
+ 4
The operating system is responsible for naming threads. Each time you run your program the OS has to name and ID the threads so it knows which processes etc belong to your program. They are named depending on what is available at the runtime of your program given all processes that are taking place at that time. When your program ends those threads are killed and no longer exist. This repeats for each time the program is ran. There is no guarantee that a programs threads will get the same name, nor is it likely, each time it is ran.
24th Nov 2020, 4:22 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
on local Windows I gets same result each run: Thread-1 Thread-2 VAMSI'S THREAD VAMSI'S 2D THREAD 200000
24th Nov 2020, 8:36 AM
zemiak