I want to run some background job without blocking user's browser which I started in Thread.
here is my code snippet :
calling from controller :
Now my problem is that thread is not sleeping and it blocks user's browser for ever ...
any help will be appriciated..
Thanks, Rishi
[BSouther: Added UBB CODE tags] [ March 05, 2008: Message edited by: Ben Souther ]
Ulf Dittmer
Marshal
Joined: Mar 22, 2005
Posts: 35241
7
posted
0
It looks as if this code will not terminate until "replaceTaskFinished" is set to true (which supposedly happens in replaceTaskThread). So you haven't really an independent thread here.
Also, if "replaceTaskFinished" is an instance variable, then this code is not thread-safe. Any write access to instance variables needs to be synchronized. But, as pointed out above, the code should not wait for it to become true to begin with.
William Brogden
Author and all-around good cowpoke
Rancher
Joined: Mar 22, 2000
Posts: 12268
1
posted
0
Hardly surprising since (as near as I can tell) you are holding on to the thread that is handling the request that started the whole thing. You should let that request terminate normally with something like a "working" HTML page and find another way to update the user. There have been a lot of discussions of this sort of thing on the ranch so do some searches.