• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

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: 76440
366
  • 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: 76440
366
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic