# multiplatform

Aleksey Zhidkov

05/28/2020, 7:45 AM
Hello I'm developing mp-project where I need a shared strucutre (actually map of immutable key-values), that potentially may be accessed from different threads, but writes will be executed from single thread. Currently I'm considering approach with coroutines and custom SignleThreadDispatcher (Default on JS, Executors-based on JVM and Worker-based on Native), but I cannot find a way of hiding freezing concept from common code. Is there some possibility to do it? I want to inject serialization of writes here: And here is map-based storage implementation:
Ok, in this post: I found, that "Note that objects will be frozen when they are transferred between threads using `withContext`" Will check it
hm, but looks like I still need some thread-safe data structure for jvm due to java memory model semantics
For history: newSingleThreadContext was added for native in 1.3.5-native-mt-1.4-M1 but reads also should be done via the same thread as writes either map should be immutable