Statische Liste Multithread -Anwendung
Posted: 11 Apr 2025, 19:36
Code: Select all
public class Helper
{
private static List timeZoneList = null;
public static List GetTimeZoneList()
{
if (timeZoneList == null)
{
timeZoneList = new List();
timeZoneList.Add(new TimeZoneMap() { Id = "Dateline Standard Time", DisplayName = "(UTC-12:00) International Date Line West" });
timeZoneList.Add(new TimeZoneMap() { Id = "UTC-11", DisplayName = "(UTC-11:00) Coordinated Universal Time-11" });
timeZoneList.Add(new TimeZoneMap() { Id = "Aleutian Standard Time", DisplayName = "(UTC-10:00) Aleutian Islands" });
}
}
Was machen wir hier falsch? ? Zweifeln Sie jedoch immer noch, dass dies die Liste nur lesen würde. Was für die erste Last bekommen wir nur 5 anstelle von allen!?