Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
Hi, I have a problem here like If there are 2 threads t1 and t2 both running in a program and my task is t2 should kill t1 and stop running. Can anyone explain this? Thanks in advance. Madhuri.
Since the stop method is deprecated, I guess that the best thing you can do is send an interrupt to the thread t2 from t1. t2's run can work while !interrupted.
The interrupt() call is not guaranteed to work. If only t1 is on a wait() call, t2 can call interrupt() to do what you want to do. I think there is a better alternative to achieve this. Use a common resource that both threads check. t2 can set the proper condition on which t1 can return and t2 can also check the same value and return.
Well, that common resource that one thread can set and the other one check -- that's the interrupted flag. No use reinventing the wheel. Cf Thread.interrupted(). - Peter
We're being followed by intergalactic spies! Quick! Take this tiny ad!
Free, earth friendly heat - from the CodeRanch trailboss