threads urgent

Reply

Join Date: Jul 2007
Posts: 24
Reputation: dmotah is an unknown quantity at this point 
Solved Threads: 0
dmotah dmotah is offline Offline
Newbie Poster

threads urgent

 
0
  #1
Jan 28th, 2008
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...
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,527
Reputation: javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light javaAddict is a glorious beacon of light 
Solved Threads: 209
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: threads urgent

 
0
  #2
Jan 28th, 2008
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.
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC