[SNMP4J] USMTable and thread safety

Girish Venkatasubramanian girishvs at gmail.com
Tue Mar 12 01:33:35 CET 2019


Yes - that was the class that I was asking (
https://www.snmp4j.org/doc/org/snmp4j/security/UsmUserTable.html)

I was under the (mistaken) impression that the synchronized keyword
prevents two threads from executing the same function simultaneously (at an
object granularity). After reading your response, I checked and understood
that event two different synchronized functions of an instance cannot be
executed simultaneously by two different threads.

So, to sum up, there is no issue. Its just my not understanding the
synchronized keyword properly. Apologies and thanks, as always, for the
clarifications.

Thanks
Girish

On Mon, Mar 11, 2019 at 5:19 PM Frank Fock <fock at agentpp.com> wrote:

>
> Hi Girish,
>
> The UsmUserTable (USMUserTable does not exists either) addUser and
> removeAllUsers methods are both synchronised.
> Thus, where exactly do you see a concurrency issue?
>
> Best regards,
> Frank
>
>
> On 11. Mar 2019, at 14:32, Girish Venkatasubramanian <girishvs at gmail.com>
> wrote:
>
> Hi Frank.
> Yes, I had the incorrect class name. Thanks for pointing that out.
>
> The class I was asking about was USMUserTable. Same questions however.
>
> Thanks
> Girish
>
>
> On Sun, Mar 10, 2019, 8:59 AM Frank Fock <fock at agentpp.com> wrote:
>
>> Hello Girish,
>>
>> A class USMTable does not exists in SNMP4J. Do you meant another class or
>> is this class from a third party?
>>
>> Best regards,
>> Frank
>>
>> > On 8. Mar 2019, at 16:57, Girish Venkatasubramanian <girishvs at gmail.com>
>> wrote:
>> >
>> > Hello
>> > I was wondering if the USMTable is thread safe.
>> >
>> > I see that the USMTable uses a TreeMap which itself is not synchronized
>> > (say, unlike a concurrent hash map).
>> >
>> > Even though the functions that access it are synchronized it would not
>> > prevent a scenario where one thread is calling removeAllUsers() and
>> another
>> > thread is invoking addUser() - yes ? Is there some synchronization
>> > mechanism that I am missing ?
>> >
>> > Would appreciate your response.
>> > Thanks
>> > Girish
>> > _______________________________________________
>> > SNMP4J mailing list
>> > SNMP4J at agentpp.org
>> > https://oosnmp.net/mailman/listinfo/snmp4j
>>
>>
>


More information about the SNMP4J mailing list