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_al 

B Dim al As ArrayList = New ArrayList()
SyncLock al.SyncRoot.GetType()
Return al
End SyncLock 

C Dim al As ArrayList = New ArrayList()
Monitor.Enter(al)
Monitor.Exit(al)
Return al 

D Dim al As ArrayList = New ArrayList()
SyncLock al.SyncRoot
Return al
End SyncLock 

+ Answer
+ Report
Total Preview: 924

Copyright © 2024. Powered by Intellect Software Ltd