Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Define Thread Safe
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
01367996
Message ID:
01368174
Vues:
8
>>What does 'Thread Safe' mean? Google search didn't turn up much in the way of explanations.
>
>It just basically means that the code will work in a multi-threaded environment and still function correctly. A lot of code isn't thread safe - imagine any code that sets a property through a method in an instance of a class. For example, if you had a loop which incremented a counter and the counter was a property. While that code is running another thread calls the same method and begins incrementing the same counter; it's pretty safe to assume your code will no longer behave correctly since you now have different threads messing with the same variable (property) at the same time. This code isn't threadsafe. Threadsafe code would ensure that multiple processes couldn't interact in bad ways (usually through some sort of locking, copying the property to a local var, etc.)

This scenario sounds like there are multiple threads running inside the same app? I guess I always thought multi-threading meant running multiple threads outside of your app.

1) Can you tell me under what kind of scenario you would use multiple threads in an app?
2) What would make it thread safe?

Thanks
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform