1 °³¿ä
static void Main()
{
double myAccount;
double yourAccount;
myAccount = 1000;
yourAccount = 500;
double amountToTransfer = 150;
myAccount -= amountToTransfer;
yourAccount += amountToTransfer;
} ½º·¹µå ¼¼ÀÌÇÁÇÏÁö ¾ÊÀº ÄÚµå. +- ÇÏ´Â ºÎºÐ¿¡¼ ´Ù¸¥ ½º·¹µå°¡ ³¢¾îµé¸é Äá°¡·ç µÈ´Ù.
static void Main(string[] args)
{
INstmObject<double> myAccount;
INstmObject<double> yourAccount;
myAccount = NstmMemory.CreateObject<double>(1000);
yourAccount = NstmMemory.CreateObject<double>(500);
using (INstmTransaction tx = NstmMemory.BeginTransaction())
{
double amountToTransfer = 150;
myAccount.Write(myAccount.Read() - amountToTransfer);
yourAccount.Write(yourAccount.Read() + amountToTransfer);
tx.Commit();
}
Console.WriteLine("My account balance: {0}", myAccount.Read());
Console.WriteLine("Your account balance: {0}", yourAccount.Read());
} STMÀ» ÅëÇØ ½º·¹µå ¼¼ÀÌÇÁÇØÁø ÄÚµå. Áï ·ÎÁ÷ ÀÚü´Â °Çµå¸®Áö ¾ÊÀ¸¸é¼ ½º·¹µå ¼¼ÀÌÇÁÇÑ Äڵ带 ¸¸µå´Â µ¥ µµ¿òÀ» ÁÖ´Â ÀåÄ¡...¶ó´Â ´À³¦. À§Å°Çǵð¾îÀÇ ¼³¸íÀ» ¿Å°Ü º¸ÀÚ¸é...
In computer science, software transactional memory (STM) is a concurrency control mechanism analogous to database transactions for controlling access to shared memory in concurrent computing. It functions as an alternative to lock-based synchronization, and is typically implemented in a lock-free way.
Áï ThreadsProgrammingÀÌ º¸Æíȵʿ¡ µû¶ó, ±âÁ¸ÀÇ ¶ôÀ» ÀÌ¿ëÇÏ´Â µ¿±âÈ ¹æ½ÄÀÌ ³Ê¹« º¹ÀâÇÏ´Ù°í ¿©°ÜÁ® ³ª¿Â ´ë¾È Á¤µµ¶ó´Â ¸»ÀÌ µÇ°Ú´Ù. ÀϹÝÀûÀ¸·Î LockFreeAlgorithmÀ» ÀÌ¿ëÇÏ¿© ±¸ÇöµÇ´Â ¸ð¾çÀÌ´Ù.
2 ¸ñ·Ï
3 ¸µÅ©
SeriousMoin v1 (koMoinMoin 1.0a4 Modified)