This ended up working ```object counter { var ...
# announcements
b
This ended up working
Copy code
object counter {
    var counter : Int = 0
    fun increment() = counter++
    fun decrement() = counter--
    fun get() = counter
}
Then I made a mutex
Copy code
val mutex = Mutex()
                            launch(CommonPool) {
                                mutex.lock()
                                try {
                                    counter.increment()
                                    //Do stuff here
                                    counter.decrement()
                                }
                                finally {
                                    mutex.unlock()
                                }
                            }
Then I checked for it in my other class
Copy code
while(counter.get() > 0) {}