# Sync.rb difference between Sync::UN, Sync::EX and Sync::SH

**URL:** <https://www.ruby-forum.com/t/sync-rb-difference-between-sync-un-sync-ex-and-sync-sh/49787>\
**Category:** Ruby\
**Created:** [December 8, 2005, 7:55pm UTC](https://www.ruby-forum.com/t/sync-rb-difference-between-sync-un-sync-ex-and-sync-sh/49787 "2005-12-08T19:55:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 8, 2005, 7:55pm UTC](https://www.ruby-forum.com/t/sync-rb-difference-between-sync-un-sync-ex-and-sync-sh/49787/1 "2005-12-08T19:55:48Z")

</div>

In sync.rb what are Sync::UN, Sync::EX and Sync::SH all about?

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 8, 2005, 8:08pm UTC](https://www.ruby-forum.com/t/sync-rb-difference-between-sync-un-sync-ex-and-sync-sh/49787/2 "2005-12-08T20:08:00Z")

</div>

Oh, one other thing. SyncEnumerator has nothing to do with Sync right?  
Maybe it would be better if were named something else (TandemEnumerator  
come to mind).

Thanks,  
T.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 8, 2005, 8:24pm UTC](https://www.ruby-forum.com/t/sync-rb-difference-between-sync-un-sync-ex-and-sync-sh/49787/3 "2005-12-08T20:24:28Z")

</div>

Trans wrote:

> In sync.rb what are Sync::UN, Sync::EX and Sync::SH all about?

EX is exclusive: if a thread requests an EX lock, no other threads may  
may hold the lock at the same time.

SH is shared: many threads may hold the lock as long as they all  
requested a shared lock.

The intent is to allow either multiple readers or a single writer (but  
not both) inside the critical section(s) of code.

---

<div class="post-metadata">

**Author:** ![transfire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/c67d28/32.png) [@transfire](https://www.ruby-forum.com/u/transfire)\
**Post date:** [December 12, 2005, 3:48pm UTC](https://www.ruby-forum.com/t/sync-rb-difference-between-sync-un-sync-ex-and-sync-sh/49787/4 "2005-12-12T15:48:00Z")

</div>

No one know? I assume Sync::EX when underlying data is gogin to change  
and Sync::SH when it’s not? Can EX just be used alwasy instead?

T.
