Hi,
I have a quick question regarding Lists in VB.NET and multi threading.
Lets say we have a list of strings, called alphabetList.
We then have 26 threads, each adding a single letter of the alphabet to alphabetList.
so...
thread1: alphabetList.add("a")
thread2: alphabetList.add("b")
...
thread26: alphabetList.add("z")
Now let us assume that we create all threads and then start them all at exactly the same time.
Would the above scenario be thread safe, ie. will there be 26 distinct elements, all added correctly to alphabetList?
My plan is to load up 100000+ words, into a list, using multiple threads and I need to know if locks will be required or if I am OK to simply add all the words in without any locking.
At present, the loading up process takes 5-8 seconds and is quite complex, involving multiple locks and threads. However, if I were to input items into the list without locking, it may speed up the loading process.
Thanks
I have a quick question regarding Lists in VB.NET and multi threading.
Lets say we have a list of strings, called alphabetList.
We then have 26 threads, each adding a single letter of the alphabet to alphabetList.
so...
thread1: alphabetList.add("a")
thread2: alphabetList.add("b")
...
thread26: alphabetList.add("z")
Now let us assume that we create all threads and then start them all at exactly the same time.
Would the above scenario be thread safe, ie. will there be 26 distinct elements, all added correctly to alphabetList?
My plan is to load up 100000+ words, into a list, using multiple threads and I need to know if locks will be required or if I am OK to simply add all the words in without any locking.
At present, the loading up process takes 5-8 seconds and is quite complex, involving multiple locks and threads. However, if I were to input items into the list without locking, it may speed up the loading process.
Thanks