Create 5 workers concurrent print out numbers from 1 to 1000. Note: for the whole result each number only can display once only. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Create 5 workers concurrent print out numbers from 1 to 1000. Note: for the whole result each number only can display once only.

Example output format: {"Worker":{"WorkerID":1, "Number":1}} {"Worker":{"WorkerID":2, "Number":3}} {"Worker":{"WorkerID":3, "Number":2}} {"Worker":{"WorkerID":4, "Number":4}} {"Worker":{"WorkerID":5, "Number":5}} ..... {"Worker":{"WorkerID":5, "Number":1000}}

1st Apr 2020, 4:37 AM
Yen San
Yen San - avatar
1 Answer
+ 1
you can use threads or background worker. for the numbers create a static field which all threads have access to that
27th Apr 2020, 7:37 AM
Ali pishkari
Ali pishkari - avatar