• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

working with two threads!!

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have two threads started off like ...

t1.start();
t2.start();

does this mean that both of them start off simultaneously one after the other at the same time?
and if the thread t2 is a timer of the thread t1, then does the timer thread gives the time taken for thread t1 to run( assuming the code for timer is working fine)?

PLease let me know
Sapna
 
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Very important point - you really cannot make any assumptions about which one starts first.
 
Sapna Korecherla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
why?
 
Paul Santa Maria
Ranch Hand
Posts: 236
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look here:

http://java.sun.com/docs/books/tutorial/essential/threads/index.html

The essential point is that when you're writing multithreaded code, you can *never* (by default) safely make *any* assumptions about "what happens when". If the processing in one thread is dependent on the activities of a different thread, then you must *always* use some kind of explicit synchronization.

'Hope that helps .. PSM
 
Sapna Korecherla
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks PSM !!
 
Everybody! Do the Funky Monkey! Like this tiny ad!
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic