I have a program thats going to be processing large amounts of data. I already have things in place so that it can stop, and resume where it left off.
I want to be able to set it going for a while (e.g. process 1000 files), but be able to escape on user input, for example:
for(int i = 0; i < 1000; i++) { if( checkForUserInput() ) { break; } processFile(i); /* * ... * */ } I know that you can prompt for user input, and if it matches some criteria then break... but I want it to default to keep running without user input.
I think I might have done this same thing a long time ago in java, and IIRC I ended up using threads --- would that be the only way to procede here as-well? Or is there a way to look for a keyboard escape sequence like Cntrl-C, and then behave a certain way?
Edit: If there is a reason why such a thing cant be done without threads, I'd be curious to know why, as-well.
Thanks!