WatchService and SwingWorker: how to do it correctly?
问题 WatchService sounded like an exciting idea ... unfortunately it seems to be as low-level as warned in the tutorial/api plus doesn\'t really fit into the Swing event model (or I\'m missing something obvious, a not-zero probability Taking the code from WatchDir example in the tutorial (simplyfied to handle a single directory only), I basically ended up extend SwingWorker do the registration stuff in the constructor put the endless loop waiting for a key in doInBackground publish each WatchEvent