Reputation: 1337
if a process is not going to finish means if it getting stucked... how can i realize it and terminate it.
i am working on a software which processes millions of files and each files takes few seconds to get process, but some files get stucked during processing, i want to **
skip those files.
** how can i do this??
details:
the files are first PARSED ------> then it is converted to .adv files ---------> later into triples .tpl
some files are getting stucked while generating .adv files.
Upvotes: 2
Views: 271
Reputation: 156
Decide how much time you are willing to spend generating one file before skipping it. You can set a timer with that time limit and check if it's still uploading the same file since the last time it went off. You shouldn't notice that much of a difference in CPU performance with just one timer that performs a simple check.
edit:
fileTimer = new Timer(maxDelay, checkFile);
fileTimer.start();
//set currentFile
ActionListener checkFile = new ActionListener() {
String lastFile;
public void actionPerformed(ActionEvent e) {
if (this.lastFile == currentFile)
//terminate process
else
lastFile = currentFile
}
}
I'm not quite sure how to terminate the process. I'm not super familiar with multi-threading. Any ideas on that @anshulkatta?
Upvotes: 1