3 ms·
Creating a new thread is equally simple in Java: var thread = new Thread(() -> { // Thread code }); thread.start(); // ... thread.joi
by Kwpolska 2y ago
Creating a new thread is equally simple in Java:
var thread = new Thread(() -> {
// Thread code
});
thread.start();
// ...
thread.join();
- speleding 2y agoYes, but it's a good example of how Java is about twice as verbose to do the same work. The Ruby version of that can be written as simply: Thread.new{ ... thread code ...}.join The extra verboseness quickly adds up if every statement takes twice as much code.
- lucasoshiro 2y agoFair. I must admit that I'm not aware of the recent features of Java. Last time I really needed it was the time that we needed to instance an anonymous class for callbacks. I still find the block syntax in Ruby cleaner though. Kotlin is another language that has this Ruby-style blocks for callbacks.