# Unlock from wrong thread

**URL:** https://discourse.julialang.org/t/unlock-from-wrong-thread/70604
**Category:** New to Julia
**Tags:** multithreading, task
**Created:** [October 29, 2021, 9:19am UTC](https://discourse.julialang.org/t/unlock-from-wrong-thread/70604 "2021-10-29T09:19:13Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![whatsthecraic](https://avatars.discourse-cdn.com/v4/letter/w/7bcc69/32.png) [@whatsthecraic](https://discourse.julialang.org/u/whatsthecraic)
#### Post date: [October 29, 2021, 9:19am UTC](https://discourse.julialang.org/t/unlock-from-wrong-thread/70604/1 "2021-10-29T09:19:13Z")

</div>

Hi there,

when unlocking a ReentrantLock from a different thread than the one that acquired the latch in the first place, julia [raises the exception “unlock from wrong thread”](https://github.com/JuliaLang/julia/blob/master/base/lock.jl). As the latch is associated to a resource, the logic of my application might pass the resource round different threads and, therefore, unlock its related latch from other threads.

Question is how to get round this limitation of ReentrantLock?

---

<div class="post-metadata">

### Author: ![pfitzseb](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pfitzseb/32/45566_2.png) [@pfitzseb](https://discourse.julialang.org/u/pfitzseb)
#### Post date: [October 29, 2021, 11:58am UTC](https://discourse.julialang.org/t/unlock-from-wrong-thread/70604/2 "2021-10-29T11:58:20Z")

</div>

You could try using a `Threads.SpinLock` instead.
