MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/java/comments/ma0y6b/java_lambdas_can_deadlock_parallel_class/grwldov/?context=3
r/java • u/fredoverflow • Mar 21 '21
46 comments sorted by
View all comments
84
TL;DW Lambda bodies are implemented as private static methods, but during class initialization, other threads are blocked from calling static methods.
38 u/[deleted] Mar 21 '21 Whilst interesting; who would do such a thing? Having a heavy static class initialiser using a parallel stream like that.. ouch. 1 u/tonywestonuk Mar 23 '21 It only needs to be done once...Isn't it better if you move the initialisation code to a one time hit? 1 u/[deleted] Mar 23 '21 Sure but you can do that in multiple ways, and specifically ways in which you can control when that hit happens.
38
Whilst interesting; who would do such a thing? Having a heavy static class initialiser using a parallel stream like that.. ouch.
1 u/tonywestonuk Mar 23 '21 It only needs to be done once...Isn't it better if you move the initialisation code to a one time hit? 1 u/[deleted] Mar 23 '21 Sure but you can do that in multiple ways, and specifically ways in which you can control when that hit happens.
1
It only needs to be done once...
Isn't it better if you move the initialisation code to a one time hit?
1 u/[deleted] Mar 23 '21 Sure but you can do that in multiple ways, and specifically ways in which you can control when that hit happens.
Sure but you can do that in multiple ways, and specifically ways in which you can control when that hit happens.
84
u/fredoverflow Mar 21 '21
TL;DW Lambda bodies are implemented as private static methods, but during class initialization, other threads are blocked from calling static methods.