Interesting...
> > Hi
> >
[quoted text clipped - 52 lines]
>
> End Module
> Public Class StringLock
>
> Private m_strSyncLockSave As String = "Save"
[SNIP]
> End Class
> Module Module1
[quoted text clipped - 12 lines]
>
> End Module
Am I missing something here?
The former example was flawed because it synchronized on a string, which
might have been interned. The example that is then posted, does the
*exact* same thing, albeit in to different instances of the same class.
I am no expert in interning, but afaik, all literal strings are intered
so in the above example "Save" will also refer to the same object!
Wouldn't it just be simpler to do a:
Private m_strSyncLockSave As new Object()
at least, thats what I usually do...
/me is confused
/Matzon
David Browne - 22 Aug 2003 14:33 GMT
> > Public Class StringLock
> >
[quoted text clipped - 29 lines]
>
> at least, thats what I usually do...
The exaple was provided to demonstrate that two instances syncronizing on a
string member variable which is initialized to a literal would share the
same Monitor -- that of the interned string.
And the recommended fix was to use a new Object() to syncronize, like you
suggested.
David