Hello, I'm new to the forums and I wanted to start off with a question.
I've made an application that calculates Prime numbers between 1 and a user defined number: X.
So what I did, cause it's a personal application was to make it use four threads (I have a quad core cpu) to calculate the numbers faster.
what I did was to divide X with 4 and make thread one do 1 - x/4
thread 2 do x + 1 to 2x.
And so on.
I made a button which makes the stuff happen:
thread0 = New System.Threading.Thread(AddressOf t1)
thread1 = New System.Threading.Thread(AddressOf t2)
thread2 = New System.Threading.Thread(AddressOf t3)
thread3 = New System.Threading.Thread(AddressOf t4)
thread0.Start()
thread1.Start()
thread2.Start()
thread3.Start()
and labels that tells me when a thread is done calculating.
And when the threads finish, they put the numbers in a Rich text box.
But the threads doesn't finish at the same time.
It's like the thread 1 finishes first then thread two and so on.
Is it because thread 2,3,4 have bigger numbers to calculate thus taking longer to to it or is it because one thread finishes then the second one starts?
idk if you guys need more info about my code but I can hook y'all up with more code if you need it.
Thanks in advance.
And excuse my english :)
I've made an application that calculates Prime numbers between 1 and a user defined number: X.
So what I did, cause it's a personal application was to make it use four threads (I have a quad core cpu) to calculate the numbers faster.
what I did was to divide X with 4 and make thread one do 1 - x/4
thread 2 do x + 1 to 2x.
And so on.
I made a button which makes the stuff happen:
thread0 = New System.Threading.Thread(AddressOf t1)
thread1 = New System.Threading.Thread(AddressOf t2)
thread2 = New System.Threading.Thread(AddressOf t3)
thread3 = New System.Threading.Thread(AddressOf t4)
thread0.Start()
thread1.Start()
thread2.Start()
thread3.Start()
and labels that tells me when a thread is done calculating.
And when the threads finish, they put the numbers in a Rich text box.
But the threads doesn't finish at the same time.
It's like the thread 1 finishes first then thread two and so on.
Is it because thread 2,3,4 have bigger numbers to calculate thus taking longer to to it or is it because one thread finishes then the second one starts?
idk if you guys need more info about my code but I can hook y'all up with more code if you need it.
Thanks in advance.
And excuse my english :)