I am running a regex in a java function to parse a document and return true if it has found the string specified by the regex and return false if it hasn\'t. But the problem
What you've done kind of looks fine to me here's how I'd modify it:
final AtomicReference resultXml = new AtomicReference();
RegexpThread rt = new RegexpThread() {
public void run() {
method2(m, urlCopy, document, resultXml);
}
};
rt.start();
try {
rt.join(6 * 1000);
} catch (InterruptedException e) {
return "y";
}
if(resultXml.get() == null) {
rt.interupt();
return "g";
}
resultXml.append(resultXml.get());
return resultXml.toString();