Back to the 2026 paper

Module 4: Exception Handling

20267m

A Java application creates several threads having different priorities. Analyse how thread priority is assigned and discuss why priority alone should not be treated as a guarantee of execution order.

Worked SolutionAI Assisted

Thread priorities

Java priorities range from Thread.MIN_PRIORITY (1) to Thread.NORM_PRIORITY (5) and Thread.MAX_PRIORITY (10). Set one using thread.setPriority(7) and inspect it with getPriority().

Priorities are hints to the scheduler, not a promise of execution order. Scheduling policies vary by JVM and operating system; threads may run in an order different from their priority. Correctness must rely on synchronization primitives (synchronized, locks, queues, latches), not priority. Avoid using priority as a substitute for coordination.

Similar questions

Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.