Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


OOP와 비교해본 Actor Model


OOP

Code Block
languagec#
title일반적 OOP에서 스레드 세이프한 객체 적성법
linenumberstrue
    public class DeepThought
    {
        private int state;

        public int State
        {
            get
            {
                lock (this)
                {
                    Thread.Sleep(3000); //나의 상태에대한 깊은 생각에 빠짐..
                    return state;
                }                
            }

            set
            {
                lock (this)
                {
                    //깊은 생각에 빠질땐 누구도 건들지 말기를 바람,그대가 멀티쓰레드라 할지라도
                    state = value;
                }                
            }
        }        
    }
var dt = new DeepThought()

Thread.new { console.log( dt.State ) }
Thread.new { dt.State=1 }

...