Please join us at the new JavaWorld Q&A Forums. Your existing login will work there. The discussions here are now read-only.


JavaWorld Talkback >> 959686

Pages: 1
JavaWorld
addict


Reged: 06/20/03
Posts: 482
Pool resources using Apache's Commons Pool Frame
      #14958 - 01/20/05 09:27 PM

Pool resources using Apache's Commons Pool Framework

Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Pool resources using Apache's Commons Pool Fra [Re: JavaWorld]
      #15024 - 01/24/05 09:19 AM

Hi,

First, I think it's a cool framework!
But I have some questions to the author:
Is there a reason for why you wait on a dummy synObj? Wouldn't it be easier and safer to just join the thread? Imagine some other threads are interested on the completition of the task. It might happen that they wait on the object even if the task has alredy completed.

(in execution order!)
thread 1. start task
thread 1. notifyAll
thread 2. syObj.wait()


Post Extras: Print Post   Remind Me!   Notify Moderator  
Murali Kosaraju
Unregistered




Re: Pool resources using Apache's Commons Pool Fra [Re: Anonymous]
      #15026 - 01/24/05 09:52 AM

If you use join(), the calling thread waits for ever, since the callee thread (the running pooled thread), never finishes the run() method. Only when we call the destroy() method, through the framework, the callee thread completes its run() method. After all, the main purpose of pooling the threads is to keep them running for as long as the pool requires.

join() method can be useful, when you are spawning a thread, that is not pooled, and wait for it to finish.

Murali


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Pool resources using Apache's Commons Pool Fra [Re: Murali Kosaraju]
      #15044 - 01/25/05 04:19 AM

Ah you are right with that. I didn't check the whole code. But the problem with the synObj remains! At least you should check the task before you call wait() on it

synchronized (task) {
while(!task.hasFinished()) {
task.wait();
}
}


Post Extras: Print Post   Remind Me!   Notify Moderator  
Anonymous
Unregistered




Re: Pool resources using Apache's Commons Pool Fra [Re: Anonymous]
      #15109 - 01/27/05 02:39 PM

That is not a problem but the code is safe, yes.

-Murali


Post Extras: Print Post   Remind Me!   Notify Moderator  
parachu
stranger


Reged: 05/17/05
Posts: 3
Re: Pool resources using Apache's Commons Pool Frame [Re: JavaWorld]
      #53448 - 09/11/07 02:02 AM


Hi All!

In my application I have all the configuration of my command objects in an xml file, on application startup I have a singleton class which reads data from the xml file and creates a command registry (hash table) which now contains information about each command, i.e name of a command, any helper classes needed to execute that command etc.

Next time when I have to execute a command (coming from a client) I get the Command info from the command registry; have to usually execute a query on command registry e.g.

commandRegistary.getCommandInfo(“Login”)
This will give me a commandInfo object from which I know that which class I have to dynamically load for this particular command (and set it’s attributes I got from client).

The main point in the above story is, I am using a singleton class for this purpose and wondering weather I should stick with this approach or create a pool of instatnces of this class and then use those instances in my application?.

Feeling embarrassed to tell you that I can’t figure out the situations where I should use resource pooling and where I should avoid pooling resources.
Yes I know about Connection/Thread pooling infect have been using those techniques but in the current case cant figure out should or shouldn’t I use resource pooling here.


Post Extras: Print Post   Remind Me!   Notify Moderator  
AthenAdministrator
journeyman


Reged: 06/05/07
Posts: 79
Loc: San Francisco, CA
Re: Pool resources using Apache's Commons Pool Fra [Re: parachu]
      #53484 - 09/11/07 08:26 PM

Hi Parachu,

You might want to try posting this question to the general forums. This article was published a couple of years ago, so the thread attached to it doesn't get near as much traffic as, say,
the Enterprise Java forum.
http://www.javaworld.com/javaforums/ubbthreads.php

--------------------
Athen O'Shea
Editor, JavaWorld.com


Post Extras: Print Post   Remind Me!   Notify Moderator  
Pages: 1



Extra information
0 registered and 1 anonymous users are browsing this forum.

Moderator:   

Print Topic

Forum Permissions
      You cannot start new topics
      You cannot reply to topics
      HTML is disabled
      UBBCode is enabled

Rating:
Topic views: 8623

Rate this topic

Jump to

Contact us JavaWorld

Powered by UBB.threads™ 6.5.5