@Override
    public void run () {
        logger.entering(loggerName, "run");

        while (true) {
            try {
                //QueueElement qe = docq.poll();
                WebQueueElement qe = (WebQueueElement) docq.poll();
                if (qe == null) {
                    Thread.currentThread().sleep(200);
                    continue;
                } else {
                    Document doc = qe.getDocument();
                    dump(doc);
                    for (FileTarget ft : qe.getFileTargets()) {
                        long startMillis = System.currentTimeMillis();
                        write(url, ft.getFileName(), ft.getImage() != null ? new ByteArrayInputStream(ft.getImage()) : new FileInputStream(ft.getSourceFile()));
                        long endMillis = System.currentTimeMillis();
                        logger.info("File " + ft.getFileName() + " dumped in " + (endMillis - startMillis) + "ms.");
                    }
                }
            } catch (InterruptedException e) {
                logger.log(Level.INFO, Thread.currentThread().getName(), e);
            } catch (Exception e) {
                logger.log(Level.WARNING, Thread.currentThread().getName(), e);
            }
        }
    }