v**o 发帖数: 64 | 1 import java.sql.*;
import java.util.*;
/**
* 连接池的实现
* @author: vago
*/
public class ConnectionPool implements Runnable {
private String driver, url, username, password;
private int maxConnections;
private boolean waitIfBusy;
private Vector availableConnections, busyConnections;
private boolean connectionPending = false;
/**
* 构造子
* @param driver java.lang.String
* @param url java.lang.String
* @param username java.lang.String
* @param password jav | m******t 发帖数: 2416 | 2 There are still several issues left in the code:
1.why is it necessary to create a new thread every time to
make a new connection?
2.the free() method relies on one assumption that
the implementation class
of Connection implement equals() properly. Or busy connections
won't be released correctly.
3.the notifyAll() call in the middle of getConnection
doesn't make much sense, because the caller thread will keep
the lock and call getConnection again, while all other threads
wakened up will simply h |
|