how to read from standard input non-blocking?

后端 未结 5 2207
南旧
南旧 2020-12-06 05:25
    long end=System.currentTimeMillis()+60*10;
    InputStreamReader fileInputStream=new InputStreamReader(System.in);
    BufferedReader bufferedReader=new Buffered         


        
5条回答
  •  旧巷少年郎
    2020-12-06 05:58

    The only reliable way would be to start a worker thread and do the actual reading inside it, while the caller thread would monitor the latency.

    If the worker thread is waiting longer that allowed, the master thread would terminate it and throw an exception.

提交回复
热议问题