如果需要很长时间,如何停止在线程中执行代码.我有一些线程一直在工作,但在线程中的代码执行太长而应用程序停止响应之后.
是否有可能,如果代码没有在30s执行线程将停止执行它并转到下一个代码...所以应用程序仍然是活着的,不会停止响应.我正在使用C#.net 3.5
我正在将所有角色都读成流.我正在使用inputStream.read读取它.这是java.io.Reader inputStream.在读入缓冲区时,如何忽略像@这样的特殊字符.
码
private final void FillBuff() throws java.io.IOException
{
int i;
if (maxNextCharInd == 4096)
maxNextCharInd = nextCharInd = 0;
try {
if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
4096 - maxNextCharInd)) == -1)
{
inputStream.close();
throw new java.io.IOException();
}
else
maxNextCharInd += i;
return;
}
catch(java.io.IOException e) {
if (bufpos != 0)
{
--bufpos;
backup(0);
}
else
{
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
throw e;
}
}
Run Code Online (Sandbox Code Playgroud)