17- Synchronized Collections

3:24 2 Højttalere 2 Kapitel 74 segmenter

Kapitel

  1. 0:03

    Sometimes we need to share a collection across many threads. So let's create a collection object collection of integers. We call it collection and set it to a new array list. Now let's create two threads and have each thread add three items…

  2. 1:48

    a look. So we have four five six one of our insertions was lost This is because we have a race condition two threads are racing or competing to modify our collection concurrently Now, to solve this problem, we can use a synchronized collect…