Use synchronize blocks instead of methods for better portability to .NET