Question

i need to start an crawl process on clicking a button if i write inside onclick the other tabs cant be accessible till the process stops i need to run the process in background.in java

Was it helpful?

Solution

Call another thread inside the "on click" callback, like this:


Thread t = new Thread(new Runnable() {  
    public void run() {  
        // your code  
    }  
});  
t.start();  

OTHER TIPS

Start it in another Thread
ref
example

If you are using Swing then this might be useful

http://download.oracle.com/javase/6/docs/api/javax/swing/SwingWorker.html

You could use "concurrent" package from Java 5:

java.util.concurrent package summary

and, in particular, a thread pool. This would be more robust, since if you couldn't handle thread termination correctly or will occasionally leave it alive you could have a resource leak.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top