Write a Java program that implements a multi-thread application that has three threads. First thread generates a random integer for every 1 second; second thread computes the square of the number and prints; third thread will print the value of the cube of the number.
1 package edu.practice.java.threading; |
OUTPUT:
Let's play
Generated number:9
Cube of 9 is 729
Square of 9 is 81
Generated number:12
Cube of 12 is 1728
Square of 12 is 144
Generated number:15
Cube of 15 is 3375
Generated number:8
Square of 8 is 64
Cube of 15 is 3375
Generated number:14
Cube of 14 is 2744
Square of 14 is 196
No comments:
Post a Comment