July 2018
Intermediate to advanced
242 pages
8h 6m
English
The performHavingLock() function allows us to provide synchronization for the function passed to it as the task parameter:
performHavingLock(ReentrantLock()) { print("Wait for it!")}
As a result, the performHavingLock() function is going to print the following output to the console:
Wait for it!
Under the hood, the inline modifier affects both the function itself and the lambda expressions passed to it. They are all going to be inlined in the underlying generated bytecode:
Lock lock = (Lock)(new ReentrantLock());lock.lock();try { String var2 = "Wait for it!"; System.out.print(var2);} finally { lock.unlock();}
If we did not use the inline modifier, the compiler would create a separate instance of the Function0 type in order ...
Read now
Unlock full access