示例#1
0
        public ThreadObject CreateAndGetResults(string content)
        {
            ThreadObject obj;

            if (_threadObjectsPool.TryGetValue(Thread.CurrentThread.ManagedThreadId, out obj))
            {
                return(obj);
            }

            obj = new ThreadObject()
            {
                StringContent = content
            };
            while (_lockVersion + 1 != Interlocked.Increment(ref _lockVersion))
            {
                _threadObjectsPool.Add(Thread.CurrentThread.ManagedThreadId, new ThreadObject {
                    StringContent = content
                });
                Thread.Sleep(1);
            }

            return(obj);
        }
示例#2
0
文件: Director.cs 项目: dezzzit/Lab1
 public Director(IBuilder builder, string content)
 {
     _result = builder.CreateAndGetResults(content);
 }