StreamPollFeeder.done (line 40) is not declared volatile, but is read in run() outside any synchronized block (line 61) while being written in waitUntilDone() inside synchronized (lock) (line 107).
When the run() thread is actively reading data (input.available() > 0 is continuously true), it never enters the synchronized (lock) block where the lock's happens-before would provide visibility. So waitUntilDone() setting done = true may never be seen by the run() thread, causing it to loop forever — and waitUntilDone()'s subsequent join() call hangs too.
Fix: declare done as volatile.
StreamPollFeeder.done(line 40) is not declaredvolatile, but is read inrun()outside anysynchronizedblock (line 61) while being written inwaitUntilDone()insidesynchronized (lock)(line 107).When the
run()thread is actively reading data (input.available() > 0is continuously true), it never enters thesynchronized (lock)block where the lock's happens-before would provide visibility. SowaitUntilDone()settingdone = truemay never be seen by therun()thread, causing it to loop forever — andwaitUntilDone()'s subsequentjoin()call hangs too.Fix: declare
doneasvolatile.