[SNMP4J] Threadpool.stop locks

Richard Tarczaly ricky at daxtechnologies.com
Tue Feb 28 21:52:37 CET 2006


Frank!

Thank you for your very quick response.

Your suggestion works like a charm. 

Thank you kindly,
Richard



Richard Tarczaly
__________________________
Software Architect
DAX Technologies Corp.
Matawan, New Jersey, 07747, U.S.
Tel:       (732) - 203 - 1784 x 114
Mobile:  (908) - 601 - 0616
Fax:      (732) - 203 - 1786
E-mail:  ricky at daxtechnologies.com

-----Original Message-----
From: Frank Fock [mailto:fock at agentpp.com] 
Sent: Tuesday, February 28, 2006 3:34 PM
To: Richard Tarczaly
Cc: snmp4j at agentpp.org
Subject: Re: [SNMP4J] Threadpool.stop locks

Hi Richard,

To fix this bug, change the run() method of TaskManager
in ThreadPool to (the first line makes the difference):

     public synchronized void run() {
       while ((!stop) && run) {
         if (task != null) {
           task.run();
           synchronized (ThreadPool.this) {
             task = null;
             ThreadPool.this.notify();
           }
         }
         else {
           try {
             wait();
           }
           catch (InterruptedException ex) {
             run = respawnThreads;
             break;
           }
         }
       }
     }

Best regards,
Frank

Richard Tarczaly wrote:
> First of I'd like to thank for the extraordinary job you made putting
> the SNMP4j together.
> 
> I'm currently using the MultiThreadedMessageDispatcher with a
Threadpool
> to loadbalance incoming request responses, and once I'm done I do the
> following steps :
> 
> 1.) Check if udp_threadPool.isIdle()
> 2.) if yes call : udp_threadPool.stop()
> 
> My problem (possibly missunderstanding) is that stop will lock at this
> point and will never finish, even if isIdle() returns true.
> 
> Therefore I must call interrupt() before stop().
> 
> Shouldn't a stop() gracefully finish and join the threads instead of
> locking up (even if isIdle returns me true) ?
> 
> 
> Thank you in advance,
> Richard
> _______________________________________________
> SNMP4J mailing list
> SNMP4J at agentpp.org
> http://lists.agentpp.org/mailman/listinfo/snmp4j

-- 
AGENT++
http://www.agentpp.com
http://www.mibexplorer.com
http://www.mibdesigner.com




More information about the SNMP4J mailing list