0

hi, i have to write a code where there will b two arrays which displays a list of 0 to 100 random numbers, then a third thread will take these twa values and find the ones common in the range 70-80 and sort them in ascending order and display it..

i dont have an idea of that plz help in...

2
Contributors
1
Reply
2
Views
9 Years
Discussion Span
Last Post by javaAddict
0

Your class must extend the Thread class and implement the run method. (void run())
When your class runs that method it is executed in parallel with any other thread, included the main(String [] args).
So just create a class that stores the random numbers in an array. Code must go in the run().
Call two instances of this class. When you call their run() methods they will be executed in parallel.
When they are done use a second class to take those arrays and do the sorting.
Don't forget to have a boolean to check when they are both(the classes the generated the numbers) done because if you call the second class for the sorting right after the threads then it will be executed without the generation of the random number being finished.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.