Reply to comment

Thread safety and Independent

You are correct; you only need to write a thread-safe data model if the program will access it from more than one thread. As long as you lock around the OnGet and OnSet, then Update Controls is thread-safe too.

I'd rather not put the lock inside the Independent, even if it is a different version. Threading is very much a concern of your application. Update Controls can't know where the boundaries should be. If you've ever used the thread-safe collections in Java, then you've probably run into this situation. Java has a thread-safe Queue, for example, but you often find that you need to do more inside the lock than just add or remove.

I agree that you should avoid lock-based concurrency, but if you need it, your app should be in complete control of it.


By submitting this form, you accept the Mollom privacy policy.