• 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 priority

 
Ranch Hand
Posts: 1491
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How to start the Test2 Thread after Test1 thread complected ?











|
 
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The whole idea of threads is that they are started at (approximately) the same time. Why do you insist on starting the two sequentially? And that has nothing to do with priorities of threads.

Straight sequential programming? Pass thread 2 to the constructor of a class which starts thread 1 in the run() method?
 
Greenhorn
Posts: 16
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There may be times when the calculations of one thread depend on the completion of another.

Thread.join() gives the programmer the ability to dictate sequential processing. Documentation is here:
https://docs.oracle.com/javase/tutorial/essential/concurrency/join.html

FYI to Kri -- there are several syntax errors in your code. Are your examples essentially intended as pseudocode to give us an idea of what you want to happen?

--Scott
 
Campbell Ritchie
Marshal
Posts: 79179
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Join does what you say: delays completion of a thread until after the other thread has completed too. It doesn't delay starting until the other thread has completed.

I am blowed if I can think of a reason why you would wish to delay starting.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic