Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using ConcurrentStack

I need to use the stack data structure to save strings. But this stack will be accessed from multiple threads. So my question is, how do I use the ConcurrentStack to add data from multiple threads?

like image 248
Yustme Avatar asked Nov 29 '22 19:11

Yustme


1 Answers

Congratulations, you have chosen the correct container for multihreaded usage. The entire class is thread-safe, and recommended for your scenario, so just party on using Push or PushRange as appropriate.

The ranges example code here uses parallelization to demonstrate multithreaded operation.

like image 132
Steve Townsend Avatar answered Dec 05 '22 10:12

Steve Townsend