Class ConnectionManager {
Queue<Connection> availableConnection;
List <Connection> allotedConnection;
ConnectionManager( Integer noOfConnections, ConnectionPoperties props ) {
//Create the no of connection objects and assign to avaialbleConnection
}
Conection getConnection() {
syncronized( this.class) {
if (availableConnection.isEmpty() ) {
throw ConnectionExhausted();
}
conn = availableCOnnection.poll();
alottledConectiion.add(conn);
}
return conn;
}
synchronized Conection releaseConnection(Connection conn) {
alottedconnection.remove(conn);
avaialbleConection.add(conn);
}
Comments
Post a Comment