java – Priorities of individual threads Android-ThrowExceptions

Exception or error:

I’ve created three separate threads to do the same task, in the for loop display the console inscription.
I gave each thread a different priority through constructions(MIN, MED, MAX)

thread1.setPriority(Thread.MIN_PRIORITY)

additionally I added stopping all threads through

final CyclicBarrier gate = new CyclicBarrier(4);

and, to run all threads in the same time.

 gate.await();
} catch (BrokenBarrierException e) {
 e.printStackTrace();
} catch (InterruptedException e) {
 e.printStackTrace();

And at the and I started all threads

thread2.run();
thread1.run();
thread3.run();

 try {
gate.await();
} catch (BrokenBarrierException e) {
 e.printStackTrace();
} catch (InterruptedException e) {
 e.printStackTrace();
}
System.out.println("DONE");

setting priorities does not give the intended effects, because the threads are executed in the order in which they were “launched” above
I am asking for help because I have no idea why the priority setting does not work.
Application running on android 4.4

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *