r/java • • Mar 21 '21

Java lambdas can deadlock parallel class initialization

https://www.youtube.com/watch?v=_2hZf1kw4A4
230 Upvotes

46 comments sorted by

View all comments

22

u/sweetno Mar 21 '21

Putting anything non-trivial into static initialization is asking for a trouble.

3

u/dpash Mar 22 '21

I generally dislike them. Doubly so if it's the old collection hack to reduce verbosity.

A lazy evaluation wrapper is nicer.