假設我有它要求用戶給予一定的輸入代碼,像這樣:時限輸入
for (condition) {
System.out.println("Please give some input");
System.in.read();
} //lets say this loop repeats 3 times and i face a problem during second iteration
,但我想給用戶在60秒的時間限制,然後扔一個例外(在這種情況下,我認爲它的TimeOutException
)。我怎麼做?
Duplicate:http://stackoverflow.com/questions/804951/is-it-possible-to-read-from-a-java-inputstream-with-a-timeout – cnicutar 2011-05-02 06:32:01