- Never call wait outside a loop, a good bug finder program will flag that one ..
wait description
- Reads of fileCount should be synchronized or you may not see the current value (ever) i.e. synchronize hasFiles ()
- pushFile calls get on terminalQueue with no memory barrier, HashMap isn't thread safe, reads AND writes should be from sync blocks if you want to use multiple threads !
Can I suggest you simply the whole thing down to synchronizing all the methods maybe (I'd avoid small sync blocks of code as invariably the author gets it wrong, yes I know performance but thats only useful if your code is correct), could you not just synchronize pushFile if you get dead lock you can get a stack trace from the OS that will list all the threads and why they're blocked <ctrl><break> Windows, post that and it should be a lot more straight forward to see why your deadlocked.
"Eagles may soar but weasels don't get sucked into jet engines" SCJP 1.6, SCWCD 1.4, SCJD 1.5,SCBCD 5