{
public void run( )
{
for ( int i= 1 ; i<= 6 ; i++ )
{
if ( i== 1 )
yield( ) ;
System .
out .
println ( "\t From thread A:i=" + i
) ; }
System .
out .
println ( "Exit from A" ) ; }
}
{
public void run( )
{
for ( int j= 1 ; j<= 8 ; j++ )
{
System .
out .
println ( "\t From thread B:j=" + j
) ; if ( j== 3 )
stop( ) ;
}
System .
out .
println ( "Exit from B" ) ; }
}
{
public void run( )
{
for ( int k= 1 ; k<= 5 ; k++ )
{
System .
out .
println ( "\t from thread c:k=" + k
) ; if ( k== 1 )
try
{
sleep( 1000 ) ;
}
{
}
}
System .
out .
println ( "exit from C" ) ;
}
}
class ThredTest
{
public static void main
( String args
[ ] ) {
A obja= new A( ) ;
B objb= new B( ) ;
C objc= new C( ) ;
System .
out .
println ( "Start thread A" ) ;
obja.start ( ) ;
System .
out .
println ( "Start thread B" ) ;
objb.start ( ) ;
System .
out .
println ( "Start thread C" ) ; objc.start ( ) ;
System .
out .
println ( "end of main thread" ) ; }
}
Y2xhc3MgQSBleHRlbmRzIFRocmVhZAp7CiAgICBwdWJsaWMgdm9pZCBydW4oKQogICAgewogICAgICAgIGZvcihpbnQgaT0xO2k8PTY7aSsrKQogICAgICAgIHsKaWYoaT09MSkKeWllbGQoKTsKICAgICAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcdCBGcm9tIHRocmVhZCBBOmk9IitpKTsKICAgICAgICB9CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJFeGl0IGZyb20gQSIpOwogICAgfQp9CmNsYXNzIEIgZXh0ZW5kcyBUaHJlYWQKewogICAgcHVibGljIHZvaWQgcnVuKCkKICAgIHsKICAgICAgICBmb3IoaW50IGo9MTtqPD04O2orKykKICAgICAgICB7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKCJcdCBGcm9tIHRocmVhZCBCOmo9IitqKTsKaWYoaj09MykKc3RvcCgpOwp9ClN5c3RlbS5vdXQucHJpbnRsbigiRXhpdCBmcm9tIEIiKTs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