2016-04-25 4 views
0

私はクエーサーには新しく、これをやってみました。 基本的に、ファイバがスレッドをブロックしているという警告が表示されます。どうして ?私は以下のようなことはできませんか?Quasarマルチファイア警告

おかげ

//in my my testclass I have this 
String websites[] = {"http://www.google.com",""http://www.lol.com",""http://www.somenoneexistantwebsite.com"}; 
      for(int i=0; i < websites.length ; i++){ 
      TestApp.getWebsiteHTML(websites[i]); 
      } 


//in TestApp 

    public static void getWebsiteHTML(String webURL) throws IOException, InterruptedException, Exception { 
      new Fiber<Void>(new SuspendableRunnable() { 
       @Override 
       public void run() throws SuspendExecution, InterruptedException { 
       WebInfo mywi = new WebInfo(); 
       mywi.getHTML(webURL); 
       } 
      }).start().join(); 
     }   

//in WebInfo 
     public static String getHTML(String urlToRead) throws Exception { 
      StringBuilder result = new StringBuilder(); 
      URL url = new URL(urlToRead); 
      HttpURLConnection conn = (HttpURLConnection) url.openConnection(); 
      conn.setRequestMethod("GET"); 
      BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); 
      String line; 
      while ((line = rd.readLine()) != null) { 
      result.append(line); 
      } 
      rd.close(); 
      return result.toString(); 
     } 

答えて

0

docsで「暴走繊維」のサブセクションを見てください。

HttpURLConnectionはスレッドブロック(あなたのクエーサーベースのアプリケーションのパフォーマンスを殺す危険がある)あまりにも多くの時間のために繊維スケジューラからスレッドを盗む避けるために、あなたはむしろHTTP client integrated with Quasar(またはintegrate one yourself)を使用する必要があります。