Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Thread Priorities 

What is a thread?  
1//A  thread is a lightweight sub-process, the smallest unit of processing. Or in 
more  general  terms  a thread of execution is the smallest sequence of programmed
instructions that can be managed independently by a scheduler 
2//A  thread,  in  the  context  of  Java,  is  the  path  followed  when  executing  a 
program.All  Java  programs  have  at  least  one  thread,  known  as  the  main 
thread. 
3//Each  thread  has  a  priority  and  that  helps  the  thread  scheduler  to  decide 
which  thread  should  start first. Whenever we create a thread, it automatically inherits 
the priority from the parent thread.  

4//Why are threads useful in java? 


4//  This  is  because Java is a multi-threaded programming language which means we 
can develop a multi-threaded program using Java.   
  5//A  multi-threaded  program  contains  two  or  more  parts  that  can  run 
concurrently,each  part  can  handle  a  different  task  at  the  same  time  making  optimal 
use of the available resources specially when your computer has multiple CPUs. 
6//  Also,  as  we  know  each  program  has  at  least  one  thread  to  run.  Each  thread 
has  a  priority.  The  thread  priority  is  nothing  but  it  just  a  number  assigned  to  each 
thread by JVM or user.  
7//Whenever we create a thread it inherits the priority from its parent thread. But 
we can also assign the priority to the thread by setPriority() method. 

Can we rely on thread priority for 


algorithm correctness? 
8//  At  any  given  time,  the  highest  priority  thread  is  running.  However,  this  isn’t 
guaranteed. The thread scheduler may choose to run a lower priority thread to avoid 


starvation.  9//For  this  reason,  use  priority  only  to  affect  scheduling  policy  for 
efficiency purposes. We shouldn’t rely on thread priority for algorithm correctness. 

Importance of thread priority in 


Java(10+1) 
5.  In  Java  threads  have  a  lot  of  importance.  Each  thread  has  a  priority  and  the 
Priorities  are  represented  by  a  number  between 1 and 10. What this number does is 
it  helps  the  thread  scheduler  to  determine  the  order  of  execution.  If  the  thread 
scheduler  decides  that  a  thread  has  a  higher  priority,  then  it  should  be  run  before 
running  the  lower  priority  threads,  i.e.  the  highest  priority  thread  is  assigned  the 
processor first and so on.  

Could anyone give an example to explain how the 


scheduler assigns priorities?(2+3) 
  Let’s  say  we  have  three  threads  thread1,  thread2,  and  thread3,  and  they  have 
priority  5,  6,  and  10  respectively.  If  all  the  three  threads  are  in  runnable  state  and 
waiting  for  the  CPU  cycle.  Then  there  is  more  chance  thread3  gets  the  CPU  first 
because  its  priority  is  high.()  But  this  isn’t  always  not  true  because  the  thread 
scheduler  decides  the  execution  of  threads  based  on  some  criteria.  This  is  why 
thread priority becomes important. 

Before we go any further can anybody 


define what multithreading is?(4+5) 
  Multithreading  in  Java is a process of executing two or more threads simultaneously 
to  maximum  utilisation  of  CPU.  Multithreaded  applications  execute  two  or  more 
threads  and  these  threads  run  concurrently.  Hence,  it  is  also  known  as  Concurrency 
in  Java.  Each  thread  runs  parallel  to  each  other.  Multiple  threads  don’t  allocate  a 
separate  memory  area;  hence  they  save  memory.  Furthermore,  context  switching 
between threads takes less time. 


Thread priority in multithreading(5+6) 
8.  To  understand  thread  priority  in  multithreading  more  easily  let  us  look  at  an 
example.  Let  us  take  a  java  application  whose  job  is  to  perform  database 
operations,  and  that  this  is  a  multithreaded  application.  If  we  have  one  thread  for 
monitoring  the  database  connection  and  for  opening  and  closing  that  connection, 
and  another  thread  for  performing  all  the  crud  operations  like  insert,  update,  etc. 
But  in the multithreading environment the JVM controls the thread priority, so we do 
not have any control over the order of execution. 

Sorry to interrupt, but wouldn’t you need the thread 


that checks the database connection to have a higher 
priority?(7) 
8//  Yes,  you will need to check for a database connection first before performing any 
operations  on  the  database.  So,  there  must  be  some  mechanism  in Java that allows 
us to assign a priority to that particular thread.  
9//Or  let  us  take  another  example:  let's  say  you  are  performing  file  handling, 
and  you  are  performing  read  and  write  operations  from  a file and that there are two 
threads  again.  10//The  first  thread  will  be  checking  at  the  folder  location  where  the 
file is, and checking to see if it is a text file and opening and closing file.  
1//Then  the  next  thread  is  going  to  be  actually  performing  the  read  or  write 
operations in that file. So, again the first thread here has to have a higher priority.  
2//  Right,  I’d  like  to  add  to  your  point.  It  will  have  to  first check whether the file 
actually  exists  at  that  particular  folder  location and only then the thread number two 
can  perform  that actual input output in that file so again third priority comes into the 
picture .  
3//So,  this  is  where  thread  priority  helps  us  in  giving  high  priority to a particular 
thread  so  in a multithreading environment. The thread scheduler assigns a processor 
to a thread based on the priority of the thread.  
4//Whenever  we  create  a  thread  in  Java  it  always  has  some  priority  assigned  to 
it  automatically.  This  parameter  can  either  be  given  by  JVM  while  creating  the 
thread or it can be given by the programmer explicitly. 

What happens if there are multiple threads which have 


the highest priority?(5+6) 
  Any  one of these threads will get picked. It is completely up to the thread scheduler 
how  to  arbitrate  between  threads  of  the  same  priority.  The  Java  programming 
language  gives  no  guarantee  that  all  the  threads  get  treated  fairly.  Of  course,  it 
would  be  desirable  if  we  serve  all  threads  of  the  same  priority  in  turn,  to  guarantee 


that  each  of  them  has  a  chance  to  make  progress.  But  it  is  at  least  theoretically 
possible  that  on  some  platforms  a  thread  scheduler  picks a random thread or keeps 
picking  the  first  available  thread.  This  is  actually  a  weakness  of  the  Java 
programming  language,  and  it  is  difficult  to  write  multithreaded  programs  that  are 
guaranteed to work identically on all virtual machines. 

Constants defined in the thread 


class(7+8) 
  The  range  of  these  priorities  varies  from  1  to  10  and  there  are  three  constant 
variables  which  are  static.  These  are  used  to  fetch  the  priority  of  the  thread.  These 
are: 
-MINPRIORITY:  This is the minimum priority that a thread can have. The value for 
this is 1.  
-NORMPRIORITY:  This  is  the  default  priority  of  a  thread  if  you  do  not  explicitly 
define it. Value for this is 5.  

9//Doesn’t the default priority for the thread depend on 


the parent thread? 
10//  Yes,  you’re  correct.  Another  constant  is  MAXPRIORITY:  This  is  the  maximum 
priority of a thread. Value for this is 10. 

9//I also remember there are some get and set methods 
in thread priority 
10//Yes, there are actually two methods for that purpose: 

- Thread.getPriority() method returns priority of given thread. 


- 1//Thread.setPriority()  method  changes  the  priority  of  thread  to  the  value 
newPriority.  This  method  throws  IllegalArgumentException  if  the  value  of 
parameter newPriority goes beyond minimum(1) and maximum(10) limit. 


2//Priority inversion 
  Priority  inversion  is  an  operating  system  scenario  in  which  a  higher  priority  process 
is  preempted  by  a  lower  priority  process.  This  implies  the  inversion  of  the  priorities 
of the two processes. 

3//Are there any problems that can occur because of 


priority inversion? 
3// Yes, there are some issues that can occur due to this. These are: 

- A  system  malfunction  may  occur  if  a  high  priority  process  is  not  provided the 
required resources. 
- 4//Priority  inversion  may  also  lead  to  implementation  of  corrective  measures. 
These may include the resetting of the entire system. 
- 4//The  performance  of  the  system  can  be  reduced  due  to  priority  inversion. 
This  may  happen  because  it  is  imperative  for  higher  priority  tasks  to  execute 
promptly. 
- 5//System responsiveness decreases as high priority tasks may have strict time 
constraints or real-time response guarantees. 

5//However,  sometimes  there  is  no  harm  caused  by  priority  inversion  as  the  late 
execution of the high priority process is not noticed by the system. 

6//Are there any solutions that can solve the issue of 
priority inversion? 
5. Some solutions of priority inversion are as follows: 

- Priority  Ceiling:  All  the  resources  are  assigned  a  priority  that  is  equal  to  the 
highest  priority  of  any  task  that  may  attempt  to  claim  them.  This  helps  in 
avoiding priority inversion. 

What about disabling interrupts?(7+8) 


5.  There  are  only  two  priorities  in  this case, i.e. interrupts disabled and preemptible. 
So, priority inversion is impossible as there is no third option. 

- Priority  inheritance:  This  solution  temporarily  escalates  the  priority  of  the  low 
priority  task  that  is  executing  to  the  highest  priority  task  that  needs  the 


resource.  This  means  that  medium  priority  tasks  cannot  intervene and lead to 
priority inversion. 

Is it possible to prevent the low priority task from blocking the high 
priority task?(9+10) 
5.  Yes,  priority  inversion can be avoided by avoiding blocking as the low priority task 
blocks the high priority task. 

- Priority  boosting:  The  priority  of  the  ready  tasks  can  be  randomly  boosted 
until they exit the critical section. 

Java daemon thread(1+2) 


6.  Daemon  thread  is  a  low  priority  thread  that  runs  in  the  background  to  perform 
tasks  such  as  garbage  collection.  A  newly  created thread inherits the daemon status 
of  its  parent.  This  is  why  all  threads  created  inside  main  method  (child  threads  of 
main  thread)  are  non-daemon  by  default  because  main  thread  is  non-daemon.  We 
can,  however,  make  a  user  thread  to  Daemon  by  using  setDaemon()  method  of 
thread class. 

Properties of daemon thread(3+4) 


.  They  cannot  prevent  the  JVM  from  exiting  when  all  the  user  threads  finish  their 
execution. 

- VM terminates itself when all user threads finish their execution 


- If  JVM  finds  a  running  daemon  thread,  it  terminates  the  thread  and after that 
shutdown itself. JVM does not care whether Daemon thread is running or not. 
- It is an utmost low priority thread. 

Methods used in the demon thread(5+6) 


void  setDaemon(boolean  status):  This  method  is  used  to  mark  the  current  thread as 
daemon thread or user thread. 

- boolean  isDaemon():This  method  is  used  to  check  that  current  is  daemon.  It 
returns true if the thread is Daemon else it returns false. 


What are some of the applications and benefits of using 
this daemon thread?(7+8) 
Daemon  threads  are  useful  for  background  supporting  tasks  such  as  garbage 
collection,  releasing  memory  of  unused  objects  and  removing  unwanted  entries 
from  the  cache.  Most  JVM  threads  are  daemon  threads  .  Their  sole  purpose  is  that 
they  provide  services  to  user  thread  for  background  supporting  task.  If  there  is  no 
user  thread,  there  is  no  need  for  the  JVM keep running this thread. That is why JVM 
terminates the daemon thread if there is no user thread. 

Let us now talk about Java thread 


pool(9+10) 
Java  Thread  pool  represents  a  group  of  worker  threads  that  are  waiting  for  the  job 
and  reuse  many  times.  This  reuses  previously  created  threads  to  execute  current 
tasks. 
Java provides the Executor framework which is centred around the Executor  
Interface, which is its sub-interface. 
They allow you to take advantage of threading, but focus on the tasks that you 
want the thread to perform, instead of thread mechanics. 

Are there any advantages to the Java thread pool?(1+2) 


  Yes,  the  Java  thread  pool  gives  better  performance  It  saves  time  because  there  is 
no need to create a new thread. 
I agree with your points mentioned here, but there are also some drawback: 

- Thread  pool  is  suitable  only  when  you use it for operations that take less time 


to  complete.  Thread  pool  threads  are  not  suitable  for  long-running 
operations,  as it can easily lead to thread starvation. If you require your thread 
to have a specific priority, then thread pool thread is not suitable. 

Thread group(3+4) 
  Java  provides  a  convenient  way  to  group  multiple  threads  in  a  single  object. 
Java.lang.ThreadGroup  class  in  Java  offers  a  convenient  way  to  manage  groups  of 


threads  as  a  unit.  The  thread  group  form  a  tree  in  which  every  group  except  the 
initial thread group has a parent. 
A  thread  is  allowed  to  access  information  about  its  thread  group  but  does  not 
have access to information about its parent group or any other thread group. 

Constructors of thread group(5) 


  

- Thread group (string name) : It creates a thread group with a given name. 
-   Thread  group  (thread  group  parent,  string  name)  -  It  creates  a  thread  group 
with given parent group and name. 

6//Methods in thread group 


6//  There  are  many  methods  in  the  thread  group  class,  but  I’d like to mention a few 
of  them.  checkAccess()  method  determines  if  the  currently  running  thread  has 
permission to modify the thread group. 
7//active  count()  returns  an  estimate  of  the  number  of  active  threads  in  the  thread 
group  and its subgroups and the get maxpriority returns the maximum priority of the 
thread group. 
8//There  are  also  methods  like  destroy() which destroys the thread group and all 
of  its  subgroups.  And  enumerate(Thread  list)  which  copies  into  the  specified  array 
every active thread in the thread group and its subgroups. 
  9//Another  method  which  I’ve  read  about  is  ParentOf(  ThreadGroup).  This 
method  tests  if  the  thread  group  is  either  the  thread  group  argument  or  one  of  its 
ancestor thread groups.  
10//.  Yes,  I’d  like  to  add  one  more  such  method.  resume()  is  again  one  such 
method  which  is  used to you know resume all threads in the thread group which was 
suspended using suspend() method. 

1//Shutdown hook 
1//The  shutdown  hook  can  be  used  to  perform  cleanup  resource  or  save  the 
state  when  JVM  shuts  down  normally  or  abruptly.  Performing  clean  resource 
means closing log file, sending some alerts or something else. 
2//  So  if  you  want  to  execute  some  code  before  JVM  shuts  down,  use  the 
shutdown hook. 
The  addShutdownHook()  method  of  Runtime  class  is  used to register the thread 
with the Virtual Machine. 


 
3//On  the  surface,  using  a  shutdown  hook  is  downright  straightforward.  All  we 
have  to  do  is  simply  write  a  class  which  extends  the  java.lang.Thread  class,  and 
provide  the  logic  that  we  want  to  perform when the VM is shutting down, inside the 
public  void  run()  method. 4//Then we register an instance of this class as a shutdown 
hook  to  the  VM  by  calling  Runtime.getRuntime().addShutdownHook(Thread) 
method. 

4//Advantages of shutdown hook 


2.  

- 5//The  important  features  of  java  virtual  machine  are  shutdown  hooks 
because  they  provide  the  capacity to do the cleanup of resources or store the 
state of the application when the java virtual machine is shutting down  
- 4//The  shutdown  hooks  can  be  executed  at  runtime  when  the  java  virtual 
machine is shutting down normally or abruptly.  
- 6//More  than  one  shutdown  hooks  can  be  registered  at  any  time  during  the 
running  of  a  java  virtual  machine  through  a  runtime application programming 
interface 

7//Disadvantages of shutdown hook 


3.  

- 7//Shutdown Hooks may not be executed in some cases 


- 7//  We  can  have  more than one Shutdown Hooks, but their execution order is 
not guaranteed. 
- 8//We cannot register/unregister Shutdown Hooks within Shutdown Hooks. 
-   8//Once  the  shutdown  sequence  starts,  it  only  can  be  stopped  by 
Runtime.halt(). 

9//Java synchronisation 
9//Multi  -Threaded  programs  may  often  have  a  situation  where  multiple  threads  try 
to access the same resources and finally produce erroneous and unforeseen results. 
So  there  needs  to  be  some  synchronisation  method  that  only  one  thread  can 
access the resource at a given point of time. 
10//Java  provides  a  way  of  creating  threads  and  synchronising  their  task  by 
using  synchronised  blocks.  Synchronised  blocks  in  Java  are  marked  with  the 
synchronised keyword. Such a block is synchronised on some object.  


1//All  synchronised  blocks  synchronised  on  the  same  object  can  only  have  one 
thread  executing  inside  them  at  a  time.  All  other  threads  attempting  to  enter  this 
block are blocked until the thread inside the synchronised block exits the block. 

2//Is there any actual need for synchronisation? 


From  what  I  understood,  the  need  for  synchronisation  originates  when  processes 
need  to  execute  concurrently.  The  main  purpose of synchronisation is the sharing of 
resources without interference using mutual exclusion.  
3//The  other  purpose  is  the  coordination  of  the  process interactions in an operating 
system.  Semaphores  and  monitors  are  the  most  powerful  and  most commonly used 
mechanisms  to  solve  synchronisation  problems.  Most  operating  systems  provide 
semaphores. 4//The producer-consumer problem (also known as the bounded-buffer 
problem),  and  the  readers-writers  problem  are  two  classical  case studies considered 
describing and test synchronisation mechanisms. 
5//  These  two  problems  are  implemented  in  various  simulation  models,  each  with  a 
different  solution  or  different  workload  parameters  to  study  the  process 
synchronisation mechanisms that can be used with interacting processes. 
6//Yes,  synchronisation  in  java  is  the  capability  to  control  the  access  of  multiple 
threads  to  any  shared  resource.  Java  Synchronisation  is  a  better  option  where  we 
want to allow only one thread to access the shared resource.  
7//Process Synchronisation is the task of coordinating the execution of processes 
in  a  way  that  no  two  processes  can  have  access  to  the  same  shared  data  and 
resources. 
8//I’d  like  to  add  to  your  points.  If  your  code  is  executing  in  a  multi-threaded 
environment,  you  need  synchronisation  for  objects,  which  are  shared  among 
multiple  threads,  to  avoid  any  corruption  of  state  or  any  kind  of  unexpected 
behaviour.  
7//Synchronisation  in  Java  will  only  be  needed  if  a  shared  object  is  mutable.  If 
your  object  is  an  either  read-only  or  immutable  object,  then  synchronisation  isn’t 
needed, despite running multiple threads. 

9//Synchronised keyword and block 


  9//  In  a  multi-threaded  environment,  it  is  possible  that  more  than  one  thread  may 
try  to  access  the  same  resource.  For  example,  two  threads  trying  to  write  into  the 
same  text  file.  Without  any  synchronisation  between  them,  it  is  possible  that  the 
data  written to the file will be corrupted when two or more threads have write access 
to the same file.  
10//To  avoid  such  issues,  Java  provides  us  with  the  synchronised  keyword,  which 
acts  like  a  lock  to  a  particular  resource.  This  helps  achieve  communication  between 

10 
threads  such  that  only  one  thread  accesses  the  synchronised  resource  and  other 
threads wait for the resource to become free. 
1//Java  provides  a  way  of  creating  threads  and synchronising their task by using 
synchronised  blocks. These blocks are marked with the synchronised keyword. When 
we  use  such  a  block,  internally  Java  uses  a  monitor  also  known  as  monitor  lock  or 
intrinsic lock, to provide synchronisation.  
2//Yes  in  fact,  all  such  blocks  synchronised  on  the  same  object  can  only  have 
one  thread  executing  inside  them  at  a  time.  All  other  threads  attempting  to  enter 
the synchronised block are blocked until the thread inside the block exits it. 

3//Differences between block and method 

3//. Though both block and method can be used to provide 


highest degree of synchronisation in Java, use of synchronised 
block over method is considered as better Java coding practices. 
- 4//  One  significant  difference  between  synchronised  method  and  block  is 
that, Synchronised block generally reduces the scope of lock. 

- 5//  As  scope  of  lock  is  inversely  proportional  to  performance,  it  is  always 
better to lock only critical section of code.  

- 4//One  of  the  best  example  of  using  a  block  is  double  checked  locking  in 
Singleton  pattern  where  instead  of  locking  whole  getInstance()  method  we 
only  lock  the  critical  section  of  code  which  is  used  to  create  Singleton 
instance.  This  improves  performance  drastically  because  locking  is  only 
required a few times. 
- 5//Synchronised  block  can  throw  throw  java.lang.NullPointerException  if 
expression  provided  to  block  as  parameter  evaluates  to  null,  which  is  not the 
case with synchronised methods. 

9.  

-   6//These  blocks  also  provide  granular  control  over  lock,  as  you  can  use 
arbitrary  lock  to  provide  mutual  exclusion  to  critical  section  code.  On  the 
other  hand,  synchronised  methods  always  lock  either  on  the  current  object 
represented  by  this  keyword  or  class  level  lock,  if  it  is  the  static  synchronised 
method. 
- 7//In  the  case  of  synchronised  method,  lock  is  acquired  by  thread  when  it 
enters  method  and  released  when  it  leaves  method,  either  normally  or  by 
throwing  Exception.  On  the  other  hand  in  case  of  synchronised  block, thread 
acquires  lock  when  they  enter  synchronised  block  and  release  when  they 
leave synchronised block. 

11 
- 8//  So  if  we  want  to  lock  the  whole  object,  we  should  use  a  synchronised 
method.  If  we  want  to  keep  other  parts  of  the  object  accessible  to  other 
threads, then the synchronised blocks are the ones we should opt for. 

9  //If  we  choose  the  locked  object  carefully,  synchronised  blocks  will  lead  to  less 
contention because the whole object/class is not blocked. 

10//Applications 
10.//  Practically,  all  server applications require some sort of synchronisation between 
multiple  threads.  Most  of  the  synchronisation  work  is  done  for  us  at  the  framework 
level, such as by our web server, database client or messaging framework. 
1//The  synchronised  keyword  in  Java  is  used  to  provide  mutually  exclusive 
access  to  a  shared  resource  with  multiple  threads  in  Java.  Synchronisation  in  Java 
guarantees  that  no  two  threads  can  execute  a  synchronised  method  which  requires 
the same lock simultaneously or concurrently. 
2//Synchronisation  in  java  comes  into  play  when  you  have  multiple  threads 
doing  certain  job,  and  you  want  them to be able to work in correspondence to each 
other when some dependent task is involved. 
3// Yes, I’d like to talk about a real life application of this 
Consider this:  
There  is  a  voting  process  going  on.  You  have  two  teams  whose  voters  can  vote 
for  -  A  and  B.  Now,  the  voting  process  will  happen  in  various  localities,  and  each 
locality  has  its  voters  and  a  collector  who  counts  the  votes.  After  the  collector  has 
collected  the  votes, they take it to a central location to add with the existing votes in 
the central box. 
4//In  this  example  the  voting  process  in  each  locality  is  like  a  thread.  Each  can 
occur independently without interfering with any of the others. 
But  when the collector comes to add the votes at the central location, they need 
to synchronise with other collectors who have also come to deposit their count. 
5//This  is  where  synchronisation  comes  in.  Both  are  not  allowed  to  access  the 
box  simultaneously,  one  has  to  wait  for  the other to finish so that he/she could work 
with the updated value. 

12 
6//Do any of the GUI toolkits like Swing, 
Javafx, etc. use threads to keep track of 
various events generated by the different 
widgets in the GUI? 
7//  In  most  configurations,  there  is  only  one  CPU.  Thus  threads  must  share the CPU 
with  other  threads.  The  execution  of  multiple  threads  on  a  single  CPU,  in  some 
order, is called scheduling.  
6//The  Java  runtime  supports  a simple, deterministic scheduling algorithm known as 
fixed priority scheduling.  
8//Each  Java  thread  is  given  a  numeric  priority,  between  MINPRIORITY  and 
MAXPRIORITY  (constants  defined  in  class  Thread).  At  any given time, when multiple 
threads  are  ready  to  be  executed, the thread with the highest priority will be chosen 
for  execution.  9//Only  when  that  thread  stops, or is suspended for some reason, will 
a  lower  priority  thread  start  executing.  Scheduling  of  the  CPU  is  preemptive  in 
nature.  If  a  thread  with a higher priority than the currently executing thread needs to 
execute, the higher priority thread is immediately scheduled. 
10//  The  Java  runtime  will  not  preempt  the  currently  running  thread for another 
thread  of  the  same  priority.  In  other  words,  the  Java  runtime  does  not  time-slice. 
However,  the  system  implementation  of  threads  underlying  the  Java  Thread  class 
may support time-slicing. Do not write code that relies on time-slicing. 
1//  If  the  currently  running  thread  yields  the  CPU  (i.e.  allows  another  thread  to 
execute  by  calling  the  yield()),  then  the  scheduler  implements  a  simple 
non-preemptive round-robin scheduling order. 
2//  In  addition,  a  given  thread  may,  at  any  time,  give  up  its  right  to  execute  by 
calling the yield() method.  
3//Threads  can  only  yield  the  CPU  to  other  threads  of  the  same 
priority--attempts to yield to a lower priority thread are ignored. 

Conclusion 
4//I  believe  we’ve  discussed  a  great  deal  about  everything.  So,  Thread priority is an 
essential  concept  since  the  scheduler  picks  up  the  threads  for  execution  based  on 
the priority. 
5//However,  thread  priorities  cannot  guarantee  that  a  higher  priority  thread  will 
always  be  executed  first  than  the  lower  priority  thread.  With  that  note  I’d  like  to 
conclude our discussion. 

13 

You might also like