Run() priority order | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Run() priority order

Hi ! I made a program in which two classes inherted Thread class and then i made the objects for both these classes and ran the program. The output for the later created obj came first and the output for the first one came out last . So is there any reason behind this ?

1st Jun 2017, 7:43 PM
Pranav Raizada
Pranav Raizada - avatar
1 Answer
+ 1
By default, every thread you create has same priority(of 5). Since they run in parallel, randomly any one of them can be executed first, even if you run 5 threads or more.
2nd Jun 2017, 6:30 AM
Deepesh Choudhary
Deepesh Choudhary - avatar