Well, the prime check works wonderfully. It does about 100,000 numbers (they're all about 106 digits long and that's skipping even numbers of course, so that's a good amount) in about 30 seconds. When I tried to do threading, each thread took 70 seconds, although I didn't check to see how many numbers they went through. For implementation of the threads, I just added "extends Thread" to my class and defined a run() section. Inside this section, it checks for the name of the thread. If it's "Test1" it goes to a certain number to start checking. If it's anything else, it goes to a second number to start.
The two threads start from staggered numbers and decrease by 4 while checking primality so as to avoid overlapping (I hope). I'm just not sure if using my original single function (the 30 second one) or the 2 threads at about 70 seconds apiece. Would love an opinion on this as well.
Edit: Realized I didn't really answer your questions. While I would prefer not to post the code (it's all original stuff using BigInteger), suffice it to say that it simply loops, starting from a given number and every 500 primes (this can be changed) it writes out to a file, which is simply a safeguard in case something messes up and the computer shuts down or anything. Also, any prime found is checked as a possible factor of the RSA number. There is no queueing of any kind outside of the threading as I haven't the faintest how to do so. Hope this helps.
Edit #2: Well, I just watched my threads run again, and it seems that while they take double the time...they're both finishing about the same time. That is, each thread is taking about the same amount of time as before. I think. I'm still a bit confused, but I'm going to let it run overnight.
If anyone can provide some recommendations on how to improve the speeds of these threads, I would be much obliged.
Last edited by wombatman; 12-14-2005 at 12:43 AM..
|