人是有惰性的

想到哪儿写到哪儿
Object synchronization method was called from an unsynchronized block of code.
转 http://msdn2.microsoft.com/en-us/library/hf5de04k(VS.71).aspx

如果x是对象就不会报错
            object x = new object();
            // The next line creates a generic object containing the value of
            // x each time the code is executed, so that Enter never blocks.
            Monitor.Enter(x);
            try {
                // Code that needs to be protected by the monitor.
            }
            finally {
                // Always use Finally to ensure that you exit the Monitor.
                // The following line creates another object containing 
                // the value of x, and throws SynchronizationLockException
                // because the two objects do not match.
                Monitor.Exit(x);
            }

posted on 2007-08-02 14:16  guanfei  阅读(1485)  评论(1)    收藏  举报