|
-
Jun 8th, 2011, 06:45 PM
#4
Re: Passing Data to a Thread Entry Method
 Originally Posted by coolcurrent4u
hello thanks jmcilhinney for this brief,
in the class approach of this threading, will this method avoid data overwriting (race condition) since the same DoWork will be used by multiple threads
since you say
vb Code:
Private Sub InitiateThread()
Dim w As New Worker
w.Data = 100
Dim t As New Thread(AddressOf w.DoWork)
t.Start()
End Sub
But it's not the same DoWork method. You're creating a new Worker object each time and each of those objects has its own Data property and DoWork method. It would only be if you used the same Worker object each time or Worker was a module or a class with Shared members that you would experience interference between threads.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|