Question:You are writing a method that returns an ArrayList named al. You need to ensure that changes to the ArrayList are performed in a thread-safe manner. Which code segment should you use?
A Dim al As ArrayList = New ArrayList()
Dim sync_al as ArrayList = ArrayList.Synchronized(al) Return sync_alB Dim al As ArrayList = New ArrayList()
SyncLock al.SyncRoot.GetType()
Return al
End SyncLockC Dim al As ArrayList = New ArrayList()
Monitor.Enter(al)
Monitor.Exit(al)
Return alD Dim al As ArrayList = New ArrayList()
SyncLock al.SyncRoot
Return al
End SyncLock
+ AnswerA
+ Report