Expt 10B
Expt 10B
UID: 2024800052
AIM:
Program 1
WelcomeThread(SharedResource r) {
resource = r;
}
DepartmentThread(SharedResource r) {
resource = r;
}
t1.start();
t2.start();
resource.startProcess();
}
}
RESULT:
PROGRAM 2
Output:
Square of 82 = 6724
Cube of 82 = 551368
PROGRAM:
class RandomGenerator extends Thread {
int num;
SquarePrinter(RandomGenerator nachiRef) {
this.nachiRef = nachiRef;
}
CubePrinter(RandomGenerator nachiRef) {
this.nachiRef = nachiRef;
}
nachi.start();
squareThread.start();
cubeThread.start();
}
}
RESULT:
CONCLUSION:
In this experiment i learned how to wait and notify. i saw how the notify
waits and then synchronises with other thread. Firstly its printed spit and
then nachiket’s electronic branch and then in 2nd question we saw how the
random function generating random number generates squares and cube.