# Is it possible to specify an object as not thread safe?

**URL:** https://discourse.julialang.org/t/is-it-possible-to-specify-an-object-as-not-thread-safe/105359
**Category:** New to Julia
**Created:** [October 24, 2023, 8:48pm UTC](https://discourse.julialang.org/t/is-it-possible-to-specify-an-object-as-not-thread-safe/105359 "2023-10-24T20:48:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![rdavis120](https://avatars.discourse-cdn.com/v4/letter/r/b5a626/32.png) [@rdavis120](https://discourse.julialang.org/u/rdavis120)
#### Post date: [October 24, 2023, 8:48pm UTC](https://discourse.julialang.org/t/is-it-possible-to-specify-an-object-as-not-thread-safe/105359/1 "2023-10-24T20:48:25Z")

</div>

Is it possible to specify the type of an object as not being safe to pass between tasks, such as a database connection or an RCall instance which is inherently synchronous? If I make a mistake I usually just get a seg fault. The analogy in Rust would be an error when trying to use an object which doesn’t implement the Send trait.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [October 24, 2023, 10:48pm UTC](https://discourse.julialang.org/t/is-it-possible-to-specify-an-object-as-not-thread-safe/105359/2 "2023-10-24T22:48:43Z")

</div>

No. The only thing you can do is add lock to all the operation to it. It really depends on what operation on the object is not safe, it would be good to have more concrete examples. Even for a DB connection or whatever, print() is thread safe, so it’s not meaningful to say everything is not thread safe.
