Clover Coverage Report - Exec Maven Plugin 1.1
Coverage timestamp: Wed Dec 31 1969 19:00:00 EST
../../../../img/srcFileCovDistChart0.png 0% of files have more coverage
19   62   5   9.5
4   46   0.26   2
2     2.5  
1    
 
  MainUncooperative       Line # 10 19 0% 5 25 0% 0.0
 
No Tests
 
1    package org.codehaus.mojo.exec;
2   
3    /**
4    * Created by IntelliJ IDEA.
5    * User: dsmiley
6    * Date: Jan 19, 2007
7    * Time: 4:43:19 PM
8    * To change this template use File | Settings | File Templates.
9    */
 
10    public class MainUncooperative extends Thread
11    {
12    public static final String SUCCESS = "1(interrupted)(f)2(f)";
13   
 
14  0 toggle public static void main( String[] args )
15    throws InterruptedException
16    {
17  0 Thread daemonThread = new MainUncooperative();
18  0 daemonThread.setDaemon( true );
19  0 daemonThread.start();
20  0 Thread.sleep( 1000 );
21    //returns to caller now
22    }
23   
24    final long SIMWORKTIME = 15*1000;//15 seconds of work which is going to be more than exec:java wants to wait
25   
 
26  0 toggle public void run()
27    {
28  0 boolean interruptedOnce = false;
29  0 long startedTime = System.currentTimeMillis();
30  0 for(int lap = 1; true; lap++ )
31    {
32  0 long remainingWork = SIMWORKTIME - (System.currentTimeMillis() - startedTime);
33  0 if ( remainingWork <= 0 )
34    {
35  0 break;//done
36    }
37  0 try
38    {
39  0 System.out.print( lap );
40  0 Thread.sleep(remainingWork);//simulates doing work
41  0 System.out.print( "(done)" );
42  0 break;
43    }
44    catch ( InterruptedException e )
45    {
46    //We want to ensure this only gets reported once. It's possible depending on a race condition for
47    // ExecJavaMojo.terminateThreads() to interrupt this thread a second time.
48  0 if ( ! interruptedOnce )
49    {
50  0 System.out.print( "(interrupted)" );
51    }
52  0 interruptedOnce = true;
53   
54    //be uncooperative; don't quit and don't set interrupted status
55    }
56    finally
57    {
58  0 System.out.print("(f)");//we should see this if Thread.stop() is called
59    }
60    }
61    }
62    }