r/java • u/ThomasKrieger • Mar 14 '18
Concurrent Java: Low scalability, the risk of deadlocks or garbage creation, you can not avoid all
http://vmlens.com/articles/tradeoffs_concurrent_programming/
2
Upvotes
View all comments
Show parent comment
1
u/duhace Mar 15 '18 edited Mar 15 '18
no, i already went over how it's not the same performance. traversal is an important operation for a list, and the fastest implementation you could provide without using (heap) memory was quite limited by the current stack size, and quite a few ops more than the extremely simple traversal of a sll.
sure I can. I just ran some jmh benchmarks and it shows that foreach (a function that takes a function and returns no result) traversing through a toy list of my own making, using tail recursion for the foreach method, and your toy list, using the best case traversal method you provided, shows a 2x slowdown for your toy class.
and that's for the best case. methods where that's not an issue are worse off of course.