× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



    Hi David,

    First, there is normally no reason to run multiple connection pools for
the same driver with properly written programs ( using JNDI to access the
pooled connections. )  Also, connection pools are seldom manually shut down.
Instead they are started up and ended by the container at start up and shut
down time.

    While the loop in the run() method never ends, there is a mechanism to
put the thread into a wait state.  That's what the setRunning(boolean
running) method and run_ variable do.  If run_ is false, the thread waits
until it is notified, which, from the code you sent, is normally done when
the value of run_ is changed via setRunning(boolean running).

    You never know for sure what people were thinking when they wrote
something, but I assume they just chose to keep the thread in memory waiting
( doing nothing ) as opposed to ending and starting a new one later.  The
basis was most likely how connection pools are expected to be used, and that
connection clean up would probably only be stopped briefly. I could see
either way as reasonable.


                                                         Joe Sam

Joe Sam Shirah -        http://www.conceptgo.com
conceptGO       -        Consulting/Development/Outsourcing
Java Filter Forum:       http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International?    http://www.jguru.com/faq/I18N
Que Java400?            http://www.jguru.com/faq/Java400


----- Original Message ----- 
From: "David Gibbs" <david@xxxxxxxxxxxx>
To: "Java Programming on and around the iSeries / AS400"
<java400-l@xxxxxxxxxxxx>
Sent: Monday, March 27, 2006 9:59 AM
Subject: Connection pool maintenance thread never ending?


> Folks:
>
> Has anyone worked with connection pools in JT400?
>
> I'm using the AS400ConnectionPool and JDBCConnectionPool for my
> application ... so far I haven't had any problems with them, but I just
> noticed something the other day.
>
> The AS400ConnectionPoolMaintenanceThread never seems to end.  And when a
> new connection pool is created, so is a new maintenance thread.
>
> >From what I can see, the run method, in the
> com.ibm.as400.access.PoolMaintenance object, does not have any ability
> to exit and shutdown.
>
> ---------
>
>   public synchronized void run()
>   {
>     if (Trace.traceOn_)
>     {
>       Trace.log(Trace.INFORMATION, "Connection pool maintenance daemon
> is started...");
>     }
>     run_ = true;
>     while (true)
>     {
>       if (run_)
>       {
>         try
>         {
>           // sleep for cleanup interval.
>           wait(pool_.getCleanupInterval());
>         }
>         catch (InterruptedException ie)
>         {
>           Trace.log(Trace.ERROR, "Connection pool maintenance daemon
> failed.");
>         }
>         pool_.cleanupConnections();
>
>         lastRun_ = System.currentTimeMillis();       // set the time of
> last run.
>       }
>       else
>       {
>         try
>         {
>           wait();
>         }
>         catch (InterruptedException e)
>         {
>           Trace.log(Trace.ERROR, "Connection pool maintenance daemon
> failed.");
>         }
>       }
>     }
>   }
>
>   /**
>   *  Sets whether the maintenance thread is running.
>   *  @param running true if running; false otherwise.
>   **/
>   public synchronized void setRunning(boolean running)
>   {
>     if (run_ != running)
>     {
>       run_ = running;
>       notify();
>     }
>   }
> ---------
>
> As you can see from the above, the entire loop is unconditional and
> never breaks out.
>
> Is this a bug, or am I just not understanding threads well enough (which
> I freely admit to not being an expert in).
>
> Thanks!
>
> david
>


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.