[SNMP4J] snmp4j and timer threads

Frank Fock fock at agentpp.com
Sun Jan 2 14:50:03 CET 2005


Hi Philip,

The listen threads of the default UDP transport mapping is already 
running as
a daemon thread. I thought anyone would call Snmp.close() before exiting
the application in order to free all allocated resources nicely. This 
does not
seem to be true. In v1.1 all threads created by Snmp and the default 
transport
mappings will all use daemon threads. However, it is strongly recommended
to call Snmp.close() anyway before exiting the application!

Best regards,
Frank

Philip Yarra wrote:

>Hi, I have been writing a simple test app to get the hang of snmp4j. So far so 
>good, but I did run into one thing that had me confused for a while:
>
>Unless I issue Snmp.close, the java.util.Timer thread continues to run 
>(Timer.cancel() is called inside Snmp.close, it seems) which prevented my app 
>from finishing normally. That could be avoided by changing the instantiation 
>of the Timer object (Snmp.java, line 157) from:
>private Timer timer = new Timer();
>to 
>private Timer timer = new Timer(true);
>to create the Timer's thread as a daemon thread, so that if all other threads 
>have completed, Timer will not prevent the app from finishing. 
>
>Does this seem a reasonable idea?
>
>I'm also happy to donate my simple test app if it will be any use (it might 
>save someone else scratching their head over why there's still an active 
>thread running).
>
>Regards, Philip.
>
>_______________________________________________
>SNMP4J mailing list
>SNMP4J at agentpp.org
>http://p15141779.pureserver.info/mailman/listinfo/snmp4j
>
>  
>





More information about the SNMP4J mailing list