I have a Java app and a C++ app that gathers a list of names from a directory. Sometimes the search could take an hour before it returns a list to iterate through. My question is that once the search begins, the app is going to run until the search is complete and it iterates the result set. What can I do if a user wants to stop the search that is running but it is still searching? I have thought of placing the search in a thread but I would have to kill the thread for outside the thread and that leaves memory leaks.