I have Java code which uses `object.wait()` and `o...
# getting-started
h
I have Java code which uses
object.wait()
and
object.notify()
. What's the best way to convert this to Kotlin? The converter in IntelliJ replaces
Object
with
Any?
, but
wait()
and
notify()
are of course not defined on
Any
.
n
thread blocking is the worst possible solution regarding thread-safety it was also the only one available in old JDK versions first, you might want to get a little information about
Future
,
CompletableFuture
, etc.
because i’m afraid it’s not worth to migrate your code directly without refactoring it
h
Thanks. I thought about passing around a
CountDownLatch
, but you're right; a bigger refactoring is probably necessary
👍 1
e
If you need to port your Java code wihtout much hassle you can use
(obj as Object).wait()
(same with
notify()
)