• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Thread little

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Suppose :
class cls extends Thread {
cls (){

}
----
----
void run (){
for ( int i =0 ; i < 10 ; i ++ )
Syatem.out.println( " i = " + i ) ;
}
public static void main ( String []args )
{
cls t1 = new cls();
cls t2= new cls();
t1.start();
t2.start();
}

}
IF they are not Synchronized , what will be thw outPut ? And if they r Synchronized then ?
Thanks
ML
[This message has been edited by lashkar (edited August 13, 2001).]
 
Ranch Hand
Posts: 2379
MySQL Database Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hi Lashkar,
The output will be i=0 upto i=9 twice consecutively. As they are two diffrent threads and not working on any object, so there is no question of synchronization here.

------------------
azaman
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic