Dungeon Hunter
Dungeon Hunter

Reputation: 20603

Connection Pooling for My Custom Application

In my Project i have a server application and a client application and one mediator application.Client communicates with the server through the mediator application.The mediator application inturn connects to the server application.

For Every client it needs to connect to the server application. I know that for every client request opening a new connection is expensive. I think i can make use of the connection pooling concept. How to implement this in java. Any pointers appreciated...

Thanks and Regards,

Sunny.

Upvotes: 1

Views: 1423

Answers (3)

Sylar
Sylar

Reputation: 2333

Use an object pooling api, such as Apache Commons Pool to implement your own pooling mechanism, or use an existing and feature rich caching solution such as Ehcache.

Upvotes: 2

kuriouscoder
kuriouscoder

Reputation: 5582

This can be made possible by using ExecutorService in java.util.concurrent package. Executors is a factory method that provides implementation for thread pools with either fixed number of threads or thread pool size bounded by the memory available.

From personal experience, fixed size thread pools are reliable than cached thread pools due to overhead involved in destroying and creating threads.

Upvotes: 0

developer
developer

Reputation: 9478

Please go through this doc, valuable information connection pooling

Upvotes: 0

Related Questions