From 6480627716b2e41d86dbd4dd8ade6dfeae2081c3 Mon Sep 17 00:00:00 2001 From: Aadit Agrawal Date: Mon, 14 Oct 2024 09:30:31 +0530 Subject: [PATCH] Upload files to "OOP/Java/Lab/Week11" --- OOP/Java/Lab/Week11/UseSetPriority.java | 34 +++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 OOP/Java/Lab/Week11/UseSetPriority.java diff --git a/OOP/Java/Lab/Week11/UseSetPriority.java b/OOP/Java/Lab/Week11/UseSetPriority.java new file mode 100644 index 0000000..bb95679 --- /dev/null +++ b/OOP/Java/Lab/Week11/UseSetPriority.java @@ -0,0 +1,34 @@ +class ThreadDemo extends Thread{ + public void run() + { + System.out.println("Inside run method"); + } +} + +class UseSetPriority { + + public static void main(String[] args) + { + ThreadDemo t1 = new ThreadDemo(); + ThreadDemo t2 = new ThreadDemo(); + ThreadDemo t3 = new ThreadDemo(); + + System.out.println("t1 thread priority : "+ t1.getPriority()); + System.out.println("t2 thread priority : "+ t2.getPriority()); + System.out.println("t3 thread priority : "+ t3.getPriority()); + + t1.setPriority(2); + t2.setPriority(5); + t3.setPriority(8); + + System.out.println("t1 thread priority : "+ t1.getPriority()); + System.out.println("t2 thread priority : "+ t2.getPriority()); + System.out.println("t3 thread priority : "+ t3.getPriority()); + System.out.println("Currently Executing Thread : "+ Thread.currentThread().getName()); + + System.out.println("Main thread priority : "+ Thread.currentThread().getPriority()); + Thread.currentThread().setPriority(10); + + System.out.println("Main thread priority : "+ Thread.currentThread().getPriority()); + } +} \ No newline at end of file