Results 1 to 3 of 3
- 10-25-2010, 08:59 PM #1
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
I need an idea with something really stupid
Hi there.
This might sound funny but I got a homework and I can`t make any sense of it.
The statement sounds like this:
"Find the 10 largest numbers in an array of 100.000 randomly generated integers. You will use threads to compare 2 numbers. A daemon thread will print at regular intervals the progress and the number of unchecked integers left."
I know it`s not appropriate to ask for help on the forum regarding a homework but I am really REALLY frustrated .... I just can`t figure out why, and how, should I use threads to deal with number comparison .....
Could you at least give me a starting idea on it ???
Sorry for wasting your time.Last edited by blf_titi; 10-25-2010 at 09:04 PM.
- 10-26-2010, 05:40 PM #2
Member
- Join Date
- Oct 2010
- Posts
- 6
- Rep Power
- 0
It sounds like this problem could have been worded a little better. From what I am understanding, you are not actually using the thread itself to compare numbers, you are simply executing the bulk of the comparison algorithm inside a seperate thread. I would recommend you start here:
Create a new thread object (which i will refer to as the 'comparison thread') which executes your block of code to run through and check all of the values in the array.
Use your daemon thread to start the new comparison thread and then enter a "sleeping" loop to print out the status of what is going on from your comparison thread. Normally, I would not put the daemon thread to sleep (i would spawn yet another thread to do the reporting) but in this example, it shouldn't hurt.
If you are not familiar with the two statements "volatile" (for variables) and "synchronized" (for methods), this would be a great time to read up on them. These two statements are used to ensure proper thread synchronization when working with multi-threading applications.
If you have any further questions, I would be happy to help.
- 10-27-2010, 03:24 AM #3
Member
- Join Date
- Jun 2010
- Posts
- 4
- Rep Power
- 0
Similar Threads
-
Stupid error
By dewitrydan in forum Java AppletsReplies: 3Last Post: 08-09-2010, 01:29 PM -
incredibally stupid....
By tek0011 in forum New To JavaReplies: 7Last Post: 11-26-2009, 09:35 AM -
simple question feel stupid asking...
By IYIaster in forum New To JavaReplies: 3Last Post: 10-02-2009, 05:04 PM -
a really stupid question
By SwinGirl in forum NetBeansReplies: 10Last Post: 06-25-2008, 09:06 PM -
Quick Stupid Question
By bluekswing in forum New To JavaReplies: 7Last Post: 01-08-2008, 06:35 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks