Use Interlocked* functions in AddRef and Release.