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 ArrayList al = new ArrayList();
lock (al.SyncRoot){
return al;
}B ArrayList al = new ArrayList();
ArrayList sync_al = ArrayList.Synchronized(al);
return sync_al;C ArrayList al = new ArrayList();
Monitor.Enter(al);
Monitor.Exit(al);
return al;
D ArrayList al = new ArrayList();
lock (al.SyncRoot.GetType()){
return al;
}
+ AnswerB
+ Report