public class ThreadInterruptMonitor extends AbstractInterruptMonitor
AbstractInterruptMonitor by starting another thread to require the interruption after sleeping user specified limit.
Remarks
One monitor instance can be used repeatedly, as long as you monitor each process in sequence. It should not be used to monitor multiple procedures concurrently in multi-threads.Example
The following example shows how to monitor the load and save procedure with specified time limit:
ThreadInterruptMonitor monitor = new ThreadInterruptMonitor(false);
LoadOptions lopts = new LoadOptions();
lopts.setInterruptMonitor(monitor);
monitor.startMonitor(1000); //time limit is 1 second
Workbook wb = new Workbook("Large.xlsx", lopts);
//if the time cost of loading the template file exceeds one second, interruption will be required and exception will be thrown here
//otherwise finishes the monitor thread and starts to monitor the save procedure
monitor.finishMonitor();
monitor.startMonitor(1500); //time limit is 1.5 seconds
wb.save("result.xlsx");
monitor.finishMonitor();
| Constructor and Description |
|---|
ThreadInterruptMonitor(boolean terminateWithoutException)
Constructs one interruption monitor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
finishMonitor()
Finishes the monitor for one procedure.
|
boolean |
getTerminateWithoutException()
|
boolean |
isInterruptionRequested()
This implementation just checks whether the time cost(from the time when starting this monitor to now) is greater than user specified limit.
|
void |
startMonitor(int msLimit)
Starts the monitor with the specified time limit.
|
public ThreadInterruptMonitor(boolean terminateWithoutException)
terminateWithoutException - AbstractInterruptMonitor.getTerminateWithoutException()public void startMonitor(int msLimit)
msLimit - time limit(ms) to require the interruption.public void finishMonitor()
Remarks
Calling this method after the monitored procedure can release the monitor thread earlier, especially when there is no interruption for it(the time cost of that procedure is less than the specified time limit).public boolean isInterruptionRequested()
isInterruptionRequested in class AbstractInterruptMonitorpublic boolean getTerminateWithoutException()
AbstractInterruptMonitor.getTerminateWithoutException().
This property is specified by user when constructing this monitor instance.getTerminateWithoutException in class AbstractInterruptMonitorSee Also:
Aspose.Cells Documentation - the home page for the Aspose.Cells Product Documentation.
Aspose.Cells Support Forum - our preferred method of support.
We guarantee a prompt response to any inquiry!
© Aspose Pty Ltd 2003-2025. All Rights Reserved.