I need to make a method in my kotlin common code s...
# kotlin-native
y
I need to make a method in my kotlin common code synchronised. What would be the best way to do this considering kotlin common doesn’t have this keyword? This method is being called from swift/kotlin. Should the methods that call into the kotlin common code be synchronised instead?
g
You can make it synchronised in you platform specific code, so annotate JVM part with
@Synchronized
I’m not sure that K/N has support of method synchronisation, there are no threads, so no need to synchronise
y
Thanks!
I just want to be sure, but in kotlin-common, there is no such as thing as `Worker`s right? That is only available in konan?
g
Correct
o
it probably means somewhat imperfect common/platform code separation, as synchronised makes no sense whatsoever in JS, and very little in Native. K/N does have threads, however it is not shared object memory threads, so synchronization on an object doesn’t usually makes sense