K. J.
Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics and Telecommunication
Engineering
Course Name: Object Oriented Programming Semester: IV
Date of Performance: ___ / ___ / ______ Batch No: Batch ___
Computer and Communication
Programme Name Roll No:
Engineering
Faculty Sign & Date: Grade/Marks: ___/15
Experiment No: 7
Title: Multithreading in Java
Aim and Objective of the Experiment:
Learn the how to do multithreading in Java
COs to be achieved:
CO4: Develop a Java application with threads and generics classes.
Tools used:
Theory:
1. Syntax of implementing thread in Java, thread group, state diagram of thread
Code:
1. Write a Java program that implements a multi-threaded program has three threads. First
thread generates a random integer every 1 second and if the value is even, second thread
computes the square of the number and prints. If the value is odd the third thread will print
the value of cube of the number. (use thread class)
2. Write a Java program which first generates a set of random numbers and then determines
negative, positive even, positive odd numbers concurrently. (use runnable interface)
3. Write a java program for to solve producer consumer problem in which a producer produce
a value and consumer consume the value before producer generate the next value.
Output:
Post Lab Subjective/Objective type Questions:
1. What does join() method?
Object Oriented Programming Semester: IV Academic Year: 2024-25
Roll No:_____________
K. J. Somaiya College of Engineering, Mumbai-77
(A Constituent College of Somaiya Vidyavihar University)
Department of Electronics and Telecommunication
Engineering
2. Is it possible to start a thread twice?
3. Can we call the run() method instead of start()?
4. What is difference between wait() and sleep()?
5. What is the purpose of the Synchronized block?
6. What is the difference between notify() and notifyAll()?
Conclusion:
Signature of faculty in-charge with Date:
Object Oriented Programming Semester: IV Academic Year: 2024-25
Roll No:_____________