This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Thread Pooling  RSS feed

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Everybody,
I have a Java Program that reads an XML document ,parses it and loads the file into a database(table).This process is for every single XML File and there are 100's of files.So its takes a very long time to load all these documents.I need to multithread this process so that the XML's can be loaded simultaneously.I am kinda confused as to what I should do.I am new to thread porgramming and so read the Sun tutorial.What strategy or design shuld I follow to multiThread this process and what is the best solution. Also,I read about ThreadPooling which is my requirement because I use a database connection pool so I need to restrict the number of threads to say 5 that run to load the XML in the database.can somebody help me with a suitable solution???The requirement is not to have container managed pool.Would appreciate if someone can direct me to some source code that has implemented this concept so that I would be able to understand the process well.This is very very urgent.Looking for Rancher's help!
Many Thanks in advance,
Prabha
 
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Seems that you are requesting two types of pool. One is database pooling, which creates a pool of database connections. The other is a file reading pool where you read more than 1 files at a time.
The database pool I use is from jakarta common project. DBCP
They also have a threadpool, althou I never used it. Threadpool
I use my own designed and implemented threadpool.
 
Prabha Dhandapani
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Adrian!
I need to do a customized Thread pool for managing the threads that simultaneoulsy access XML Files.I have no idea of how to implement a Threadpool. I am looking for some source code that would show me a direction to implement my own ThreadPool.Would appreciate if u can give me some sort of a sample code that handles say 5 threads.Looking for some help!
Many Thanks,
Prabha
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this one:
you might have to register tho:
Threadpool
You can also look at the code from jakarta common threadpool.
 
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Jakarta Commons Threadpool is surprisingly and pleasingly simple. I'd be tickled if somebody tried it and told us all how it worked out.
JDK 1.5 will have this stuff built in, largely based on work by Doug Lea I think. You can google for Doug's thread utilities and find that they are not surprisingly and pleasingly simple. But they might be a lot more robust.
 
Adrian Yan
Ranch Hand
Posts: 688
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stan, I was looking at it, and wanted try it out. But it appears that it's only in source code. I cvsed it, and having a hell of time trying to get it compiled. It seems that MAVEN is required. I spend the last hour trying to get it to work, to no avail.
Can you give me some pointers?
 
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Stan]: JDK 1.5 will have this stuff built in, largely based on work by Doug Lea I think.
In fact the 1.5 beta is available now. Check out the java.util.concurrent package. At the moment it seems to be missing a nice tutorial, but the components seem easy enough to use. Here's a simple demonstration:

[ February 24, 2004: Message edited by: Jim Yingst ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Wow, the Jakarta stuff requires Maven? I missed that. I just read the code online. Looked like only a couple very straightforward classes. I liked the blocking queue better than one we wrote a couple years ago.
 
Ranch Hand
Posts: 285
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The jakarata stuff does not require maven. Just get the jar. I use it.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!