≈ the.bay.news

GetOrAdd Ran My Factory Three Times

DEV Community
GetOrAdd Ran My Factory Three Times
ConcurrentDictionary.GetOrAdd can run your value factory more than once when threads race on the same key. Only one result is kept, but the extra factories still execute. Here's the race and the one-line Lazy<T> fix.

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.