1
香港專業教育學院得到了下面的代碼作爲一種一個Hello World試驗的的Restlet像個單線程的Restlet服務器
public static void main(String[] args) throws Exception {
//Find a way to get these from the ARGS...
Settings.setCurrent(new Settings());
// Create a new Restlet component and add a HTTP server connector to it
component.getServers().add(Protocol.HTTP, 8182);
component.getContext().getParameters().add("maxThreads", "512");
component.getContext().getParameters().add("minThreads", "100");
component.getDefaultHost().attach("/findMissingPackages", Jeblet.class);
// Now, let's start the component!
// Note that the HTTP server connector is also automatically started.
component.start();
}
@Get
public String toString() {
try {
Thread.sleep(10000);
}
catch(Exception ex) { }
String settingString = "stuff";
return settingString;
}
我遇到的問題是,如果我在Chrome中打開兩個標籤和訪問服務器的兩倍一行需要20秒鐘才能在第二個選項卡上獲得響應。這兩個選項卡應該需要10秒鐘。
當我調試我只有一個調度器。我如何告訴restlet我想要多個線程?
我結束了剛剛使用鉻和Safari瀏覽器 –