// System.Threading.Mutex semafor;

        /*    public void Myprint()
         *  {
         *      while (!this.t_finished)
         *      {
         *          Thread.Sleep(2000);
         *          Console.WriteLine("Agent o id: " + Id + " Stan konta :" + bank.stan_konta);
         *      }
         *  } */
        public BankClientAgent(int id, ref BankAgent bank, int zmiana_stanu, ref Object myLock) : base(id)
        {
            this.zmiana_stanu = zmiana_stanu;
            this.bank         = bank;
            this.myLock       = myLock;
            base.timeStep     = 0.5f;


            //  this.t = new Thread(this.Myprint);
            // this.t.Start();
        }
Beispiel #2
0
        static List <IRunnable> GenerateRunnables()
        {
            var runnables = new List <IRunnable>();
            int id        = 0;


            Object myLock = new object();
            var    bank   = new BankAgent(id, ref myLock);

            runnables.Add(bank);
            for (; id < 10; id++)
            {
                if (id % 2 == 0)
                {
                    runnables.Add(new BankClientAgent(id, ref bank, 1, ref myLock));
                }
                else
                {
                    runnables.Add(new BankClientAgent(id, ref bank, 2, ref myLock));
                }
            }

            return(runnables);
        }