|
|
|
|
|
by dikei
884 days ago
|
|
The first issue is your second code is not Java (no await/async literal for Java yet) The second issue is they're not completely equivalent. In the second case, you'd need extra memory for the `reentrantLock`, while `synchronized` works with any object. Furthermore, if you need to use `wait/notify`, then there need to be an extra `Condition` object to use in combination with the `ReentrantLock`. For sure, developers can rewrite most `synchronized` to use `ReentrantLock` and `Condition`, but javac won't do it automatically for you. |
|
C# introduced:
So you dont have to type:IAsyncEnumerator<int> e = RangeAsync(10, 3).GetAsyncEnumerator();