Statische Liste Multithread -Anwendung

Post a reply

Smilies
:) :( :oops: :chelo: :roll: :wink: :muza: :sorry: :angel: :read: *x) :clever:
View more smilies

BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: Statische Liste Multithread -Anwendung

by Anonymous » 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" });
}
}
Die TimeZonelist wird in einer Instanzklasse initialisiert (Helfer), aber es ist eine statische Liste. Dies geschieht nur für 2 bis 3 zufällige Instanz aus den 200. < /p>
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!?

Top