java - One thread dependent on the other -


If there are 4 threads running, and want if the t1 thread completes its instruction, and ends, and It is necessary that T2 should be terminated even after the T1 is over, its instructions have not been completed, while T3 and T4 are still running, it is only dependent on T2, nor on T3 Neither on T4

Someone has suggested to make me a T2 daemon, but it will depend on T3 as well as T2 on T4. Can anyone help me do that?

You can apply using.

This is a synchronization support that waits for one or more threads until another thread completes a set of operations. A versatile synchronization on the device and can be used for many purposes A countdown launch started with a countdown number, which acts as a simple / close link, or gate: all the threads that wait at the gate Do not wait until it opens with a thread countdownown (). A calculation dotlach introduced for N can be used to wait for a thread until N. Threads has not completed some work, or some work has been completed N times.

Code snippet -

  countdown is drawn to sign = new countdown (1); // Share the same object between two thread threads T1 (public zeros run) {doneSignal.await (); // T1T2 will wait till Finasheet ...}} ... Thread T2 {Public Zero Run () {... doneSignal.countDown (); // T2 sending a complete signal}}    

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -