# Kotlin Native Model use to iOS create a singletons, call fun in async Thread, Crash

**URL:** <https://discuss.kotlinlang.org/t/kotlin-native-model-use-to-ios-create-a-singletons-call-fun-in-async-thread-crash/13532>\
**Category:** Native\
**Created:** [July 19, 2019, 5:47am UTC](https://discuss.kotlinlang.org/t/kotlin-native-model-use-to-ios-create-a-singletons-call-fun-in-async-thread-crash/13532 "2019-07-19T05:47:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hxxyyangyong](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/hxxyyangyong/32/6571_2.png) [@hxxyyangyong](https://discuss.kotlinlang.org/u/hxxyyangyong)\
**Post date:** [July 19, 2019, 5:47am UTC](https://discuss.kotlinlang.org/t/kotlin-native-model-use-to-ios-create-a-singletons-call-fun-in-async-thread-crash/13532/1 "2019-07-19T05:47:35Z")

</div>

Uncaught Kotlin exception: kotlin.native.IncorrectDereferenceException: illegal attempt to access non-shared xxx@7a378d8 from other thread

---

<div class="post-metadata">

**Author:** ![Artyom.Degtyarev](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@Artyom.Degtyarev](https://discuss.kotlinlang.org/u/Artyom.Degtyarev)\
**Post date:** [July 19, 2019, 8:23am UTC](https://discuss.kotlinlang.org/t/kotlin-native-model-use-to-ios-create-a-singletons-call-fun-in-async-thread-crash/13532/2 "2019-07-19T08:23:38Z")

</div>

Hello, @hxxyyangyong! What exactly you were trying to do here? Some additional info would make the case clearer in view. It looks like you are violating Kotlin/Native concurrency rules. I mean _mutable XOR shared_, that is described [here](https://kotlinlang.org/docs/reference/native/concurrency.html)

---

<div class="post-metadata">

**Author:** ![hxxyyangyong](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/hxxyyangyong/32/6571_2.png) [@hxxyyangyong](https://discuss.kotlinlang.org/u/hxxyyangyong)\
**Post date:** [July 31, 2019, 7:30am UTC](https://discuss.kotlinlang.org/t/kotlin-native-model-use-to-ios-create-a-singletons-call-fun-in-async-thread-crash/13532/3 "2019-07-31T07:30:29Z")

</div>

I maintain a KN model static variable in oc, and then use this static variable in the child thread.
