Companion object, global vals, etc


#1

Playing with multiple threads and have some thoughts. I know native is taking a position on multiple threads, and I’m rethinking architectural design as a result. Have some questions, though.

My demo app was crashing during companion object initialization. Each worker was calling into a companion object for “static” functionality. Each separate thread seemed to be re-initializing the companion object, and they were all referencing a val that was defined globally, which was null.

I absolutely understand how horrific that sounds from a multithreading perspective, but just wanted to confirm that this sounds like expected behavior. Each thread has it’s own companion object and global val set. Also, I’m assuming that’s not what jvm does, but is it?

Moved everything to be passed around to workers, but that will force a deeper reorg for the underlying interop classes. I think, anyway. Still getting head around how threading and memory work in native.


#2

Never mind. Top level state isn’t shared with different workers by design.