이 (다른 클래스 내부에) 내의 Runnable 객체입니다) (주
private class StopFileCopy implements Runnable
{
ObjectInputStream st;
public Runnable(ObjectInputStream st)
{
this.st = st;
}
public void run()
{
if(st.read())
stopWritingToFile = true; // stopWritingToFile is an instance variable of the
// class that contains this StopFileCopy class
}
}
이제 문제는 정수가 또는 스트림 '에 기록되지 않을 수 있는지 성'. 그렇지 않다면 클래스 외부에서 즉시이 StopFileCopy 객체를 중지해야합니다. 이것을 어떻게 할 수 있습니까?
왜 Runnable 자체를 중지하지 않는 것이 좋을까요? –
@biovamp, st.read() 메서드는 스트림 'st'에서 정수를 읽으려고 계속합니다. StopFileCopy 클래스에 run() 메서드가 스트림에서 읽는 중 멈추어야한다고 알릴 수있는 방법에 대해 알지 못합니다. –
그냥 '반환'. –