Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Threads' dependency on another thread  RSS feed

 
Abrahim Daver
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi There,

Can we make a thread dependent on other thread?
I mean to say, a thread can only perform a particular task, once another thread completes its task.
Is this kind of activity possible with thread management?

Thanks in advance,
Abra D.
 
Edward Harned
Ranch Hand
Posts: 291
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are many methods. Take a look at the concurrency package:
CyclicBarrier, CountDownLatch etc.

You can use wait/notify and join etc. Many methods.
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Abrahim:
I mean to say, a thread can only perform a particular task, once another thread completes its task.

If you know which instance of thread you have to wait for, then you may use Thread.join() otherwise you can use wait & notify mechanism to co-ordinate between threads.
This article will tell you a few things about wait-notify.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!