• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

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
 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic