2013-09-22 32 views
0

所以ATM我的代碼看起來是這樣的:Java方法等待,然後重新執行?

FetchUpdates() { 
if (checkupdatesComplete) { 
    FetchUpdatedsneeded(); 
    }else{ 
    //wait until checkupdates == true, then re execute FetchUpdates(); 
    } 

差不多卻困else語句...任何人都知道爲了什麼我把「//」的方法?

這是我知道如何在檢查所需更新後調用FetchUpdates方法的唯一方法。

static File f = new File("C:\\Users\\Directory"); 
static File f1 = new File("C:\\Users\\File"); 

public void checkforUpdates() { 
if (f1.exists) { 
checkVersion(); 
}else{ 
F1Exists =false; 
} 
FetchUpdates(); 
} 

Public void FetchUpdates() { 
if (!F1Exists) { 
try (InputStream in = URI.create("C:\\DownloadUrlHere").toURL().openStream()) { 
        Files.copy(in, Paths.get("C:\\DirectoryHere")); 
       }catch(Exception ex){} 
} 
+0

這不是一個做你的,作業現場 – redFIVE

+0

你應該給予一些細節.... – JNL

+0

目前還不清楚你的環境是什麼(ATM =「禁慾「直到婚姻」?「Adobe類型管理器「?」Air Turbine Motor「?),但在大多數環境中(圖形應用程序,服務器等),不應該在程序中」等待「。 –

回答

0
while(!checkupdates){ 
     FetchUpdatedsneeded(); 
     if (checkupdates) { 
      execute FetchUpdates();   
      break; 
     } 

} 
0

而不是檢查更新時checkupdates設置爲true,只取更新時FetchUpdates叫的。

+0

不要在這樣的通話中放入一堆代碼。 – tbodt

+0

把它向後撇號,關鍵是在退出鍵下。 – tbodt

+0

我把代碼放在主帖子中,因爲它不起作用 – Ryan

相關問題