Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Last;
- import java.util.*;
- public class aaaa implements Runnable {
- Thread t1, t2;
- public static void main( String[] args )
- {
- new aaaa( ).go( );
- }
- public void go( )
- {
- t1 = new Thread( new aaaa( ) );
- t2 = new Thread( new aaaa( ).new bbb( ) );
- t1.start( );
- t2.start( );
- }
- public void run( )
- {
- for( int i = 0 ; i < 1000 ; i++ )
- {
- if( i == 200 )
- {
- if( t2.isAlive( ) )
- t2.interrupt( );
- }
- System.out.println( "**********" + i+ " **********" );
- }
- }
- class bbb implements Runnable {
- public void run( )
- {
- for( int i = 1000 ; i < 4000 ; i++ )
- {
- if( Thread.interrupted ( ) )
- {
- System.out.println( "We Have Been Interrupted!!" );
- return;
- }
- System.out.println( i );
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement