Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using SyncLock
Message
De
24/01/2011 13:58:32
 
 
À
24/01/2011 13:47:52
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Versions des environnements
Environment:
VB 9.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01496120
Message ID:
01497242
Vues:
59
>>>>John Skeet shows an implementation (C#) here w/o explicit locking.
>>>>
>>>>http://csharpindepth.com/Articles/General/Singleton.aspx
>>>
>>>I cannot access that page. But, isn't it the same as previously reported in this thread where this cannot apply in VB.NET?
>>
>>Seems so - It was method number 4 I was trying to sell you
>
>
>Ah, I apologize. I hadn't read the whole thread in detail.
>
>What was the issue with method 4?

From what I have understood

http://msdn.microsoft.com/en-us/library/ff650316.aspx


Static initialization is suitable for most situations. When your application must delay the instantiation, use a non-default constructor or perform other tasks before the instantiation, and work in a multithreaded environment, you need a different solution. Cases do exist, however, in which you cannot rely on the common language runtime to ensure thread safety, as in the Static Initialization example. In such cases, you must use specific language capabilities to ensure that only one instance of the object is created in the presence of multiple threads. One of the more common solutions is to use the Double-Check Locking [Lea99] idiom to keep separate threads from creating new instances of the singleton at the same time.


It's not entirely clear to me what the 'cases' are
Gregory
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform