从SVNRepositoryFactoryImpl javadoc:
下面是一个包含2个存储库(单线程)的示例代码:
SVNRepositoryFactoryImpl.setup(); // ONCE!
String url1 = "svn://host1/path1";
SVNRepository repository1 = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url1));
String url2 = "svn://host2/path2";
SVNRepository repository2 = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url2));
在多线程环境中,您可以创建一个实现Runnable的类:
public class ProcessSVN implements Runnable {
private String url;
public ProcessSVN(String url) {
this.url = url;
}
public void run() {
SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(url));
// do stuff with repository
}
}
SVNRepositoryFactoryImpl.setup(); // STILL ONCE!
(new Thread(new ProcessSVN("http://svnurl1"))).start();
(new Thread(new ProcessSVN("http://svnurl2"))).start();