-
Notifications
You must be signed in to change notification settings - Fork 0
/
09-statuschecks.cfc
49 lines (39 loc) · 1.28 KB
/
09-statuschecks.cfc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
component extends="../BaseTask" {
function init(){
super.init();
variables.threadPool = asyncManager.newExecutor( "myThreads" );
}
function run(){
var future = asyncManager
.newFuture( () => {
while ( true ) {
sleep( 500 );
print.greenLine( "to infinity and beyond..." ).toConsole();
}
return -1;
}, threadPool )
.completeOnTimeout( 0, 5000 );
print.greenLine( "Siesta time..." )
sleep( 2000 );
print.blueLine( "done? " & future.isDone() )
.blueLine( "exception? " & future.isCompletedExceptionally() )
.blueLine( "cancel? " & future.isCancelled() )
.line()
.toConsole();
print.greenLine( "Siesta time..." )
sleep( 1000 );
// future.cancel( true );
// print.blueLine( "done? " & future.isDone() )
// .blueLine( "exception? " & future.isCompletedExceptionally() )
// .blueLine( "cancel? " & future.isCancelled() )
// .line()
// .toConsole();
// if ( future.isDone() && !future.isCompletedExceptionally() && !future.isCancelled() ) {
// print.blueLine( "Finished! #future.get()#" ).line();
// }
// Without this, sometimes you can have threads that never finish.
print.line( "Shutting down the thread pool" ).toConsole();
threadPool.shutdownNow();
print.line( "Thread pool shut down" ).toConsole();
}
}