Persisting thread after redeploy JBoss 6.1.0

132 views Asked by At

I'm deploying an EAR with a jar in the lib folder of the ear. This jar spawns a DefaultFileMonitor thread (from the Apache Commons api) and watches a file.

When I use twiddle to do a redeploy of the EAR, the undeploy that is called for all the WARs doesn't seem to kill the DefaultFileMonitor thread.

The issue is that will keep multiple DefaultFileMonitor open on the same file and it is causing issues.

What is the proper way to kill this thread? Is twiddle to blame here?

1

There are 1 answers

0
sandak On
public enum Logger {
    INSTANCE;
    DefaultFileMonitor fm = new DefaultFileMonitor(new CustomFileListener());
    private FileObject file = null;
    private FileObject object = null;

    private Logger() {

    this.openFile();

    try {
        FileSystemManager fsManager = VFS.getManager();
        file = fsManager.resolveFile(this.getfileLocation());
        object = fsManager.resolveFile("c:\test.txt");
    } catch (FileSystemException e) {
        e.printStackTrace();
    }

    fm.setDelay(1000);
    fm.addFile(file);
    fm.start();
}

Here is the code that I'm using to load the DefaultFileMonitor