Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. COI read that I should use both [here](http://docs.oracle.com/javase/1.4.2/docs/api/java/util/Collections.html#synchronizedMap(java.util.Map)). I will be using an iterator with it in the low priority thread, and adding and removing items in the high priority thread. So do I only need to use `synchronized` when I'm iterating?
      singulars
    2. COIn that case I wouldn't be mixing them so that it was obvious what was going on in the code. The synchronized here is very important (as pointed out) because the iterator can't start and release the lock for you. I would use just any old Map implementation, have some sort of lock object and go synchronize(lock) { map.get() }, same for put and iteration operations. If your low priority thread is doing the iteration, you may be able to check for interruptions, break out. Then continue later. A processing queue might be an alternative if you just need to process new items that come into the map.
      singulars
    3. COYou are misinterpreting the Javadoc you link to. It warns that **if using `synrchronizedMap` you still need to synchronize iteration**. It doesn't say that you must **always use both**. In fact, using only `synchronized` blocks is enough and in fact preferred. If all your map accesses are within a `synchronized` block, the map itself being wrapped by `synchronizedMap` is redundant. Also, if mixing synchronizations, be **very careful** which locks you use.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload