Question: (a) Describe what a thread is in Java. How do processes and threads relate to each other? Explain why one would use multithreading. (5

(a) Describe what a thread is in Java. How do processes and threads relate to each other? Explain why one would use multithreading. (5 marks) (b) Describe what a deadlock is and how this issue can occur while using threads. (6 marks) (c) Threads can be started in two ways in Java. Describe how and write two programs, one for each way, of which each starts 5 threads. Each thread should write to System.out what position it was started in. The first thread to start will write 1, and the last will write 5. (5 marks) (d) Write a simple threaded program with a race condition issue and write a threaded program with equivalent functionality that avoids the race. (4 marks) Answer the following: (a) Java has three access modifiers. Wite a simple program (code snippets) to show the use of these access modifiers on variables and methods. Use proper comment or brief explanation to justify the accessibility or non-accessibility of the variable and the methods (i.e., restriction posed by the access modifier). (12 mark) (b) What are Overloading and Overriding concepts; how they are different from each other? Show an example program that demonstrates both Overloading and Overriding. (8 marks)
Step by Step Solution
3.53 Rating (160 Votes )
There are 3 Steps involved in it
a In Java a thread is the smallest unit of execution within a Java program It represents a separate path of execution for a Java application Threads allow a program to perform multiple tasks concurren... View full answer
Get step-by-step solutions from verified subject matter experts
