Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You've shows us how map <code>Tabs</code> is created (Java naming conventions would dictate its name begin with a lowercase letter), but not how it is populated. As it is, the map would always be empty, and the while loop would run zero times. Also, the local variable <code>tabname</code> is unused, but presumably is not unused in your actual code.</p> <p>That said, it appears that <code>ProcessEvent</code> will be run once for every event. It is static, and synchronized, which means that it will obtain the monitor for <code>MainActivity.class,</code> and no other method that synchronizes on the same object can run at the same time.</p> <p>However, it starts a new thread, which does the actual work, and returns immediately. That thread is not synchronized, and so any number of these worker threads can be running at the same time, all using the same map. The map is wrapped with <code>Collections.synchronizedMap</code> and that is the only protection against concurrent modifications.</p> <p>Such a synchronized map will not allow multiple callers to call its methods at the same time, but separate calls to different methods can be interleaved arbitrarily. For instance, while one caller is putting a new entry into the map, no other caller can access the map. However, it is possible for one caller to get the key set from the map, get the iterator from the key set, and start iterating over it, and then for another caller in another thread to add, modify, or remove an entry, and, finally, for the first thread to continue iterating over the key set and get a <code>ConcurrentModificationException.</code></p> <p>I would suggest using <code>java.util.concurrent.ConcurrentHashMap</code> instead, and removing the synchronized keyword from <code>ProcessEvent.</code></p>
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

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