当我使用注释//driver = new PhantomJSDriver(desiredCapabilities);
运行此代码时,一切正常。我只能看到两个" PhantomJS"系统过程。
2 process但是,如果我使用未注释的driver = new PhantomJSDriver(desiredCapabilities);
运行此代码,则数量为#34; PhantomJS"系统处理超过2:more than 2 ...为什么?
PhantomJsDriverManager.getInstance().setup();
Semaphore s = new Semaphore(2);
for (int i = 0; i < 10; i++) {
s.acquire();
new Thread() {
public void run() {
PhantomJSDriver driver = new PhantomJSDriver();
try {
DesiredCapabilities desiredCapabilities = new DesiredCapabilities();
System.out.println("Start: " + getName());
desiredCapabilities.setJavascriptEnabled(true);
driver = new PhantomJSDriver(desiredCapabilities);
driver.get("https://community.oracle.com/");
driver.quit();
System.out.println("Stop: " + getName());
} catch (Exception e) {
driver.quit();
} finally {
driver.quit();
s.release();
}
}
}.start();
}
}