InterviewSolution
| 1. |
What Is The Output Of This Program? 1. Class Newthread Implements Runnable { 2. Thread T; 3. Newthread() { 4. T = New Thread(this,"new Thread"); 5. T.start(); 6. } 7. Public Void Run() { 8. T.setpriority(thread.max_priority); 9. System.out.println(t); 10. } 11. } 12. Class Multithreaded_programing { 13. Public Static Void Main(string Args[]) { 14. New Newthread(); 15. } 16. } |
|
Answer» Thread t has been made with DEFAULT PRIORITY value 5 but in RUN method the priority has been explicitly changed to MAX_PRIORITY of class thread, that is 10 by code ‘t.setPriority(Thread.MAX_PRIORITY);’ using the setPriority function of thread t. Output: $ javac multithreaded_programing.java Thread t has been made with default priority value 5 but in run method the priority has been explicitly changed to MAX_PRIORITY of class thread, that is 10 by code ‘t.setPriority(Thread.MAX_PRIORITY);’ using the setPriority function of thread t. Output: $ javac multithreaded_programing.java |
|