Click to See Complete Forum and Search --> : araylist question


vivendi
April 7th, 2009, 05:51 AM
Hey, i have a quick question about the following arraylist:

private System.Collections.ArrayList m_workerSocketList = ArrayList.Synchronized(new System.Collections.ArrayList());


I mean, there is an arraylist created which is a 'Synchronized' arraylist...? Could someone please explain me what this is used for..?? It's kinda confusing :(

boudino
April 7th, 2009, 08:33 AM
It is thread-safe instance of array list, thus means that you can access it from more then one thread without need to play with locking or other synchronization stuff.

toraj58
April 7th, 2009, 10:17 AM
wow, that's gr8....but it may be a tradeof between using that trick and lock. as i know the lock is the fastest locking mechanism.