Regards
Azrael Noor
Azrael Noor wrote:1) Is while loop better way to keep threads on, on fly? or should we use another concept?
Regards
Azrael Noor
Regards
Azrael Noor
Regards
Azrael Noor
Azrael Noor wrote:
Is this spinlock as i have read:
The longer a lock is held by a thread, the greater the risk that it will be interrupted by the OS scheduler while holding the lock.
> I am unaware of producer consumer model functionality, could you provide me any link regarding these?
Azrael Noor wrote:I have searched around mostly people are fine with this paradigm, some are saying to follow:
or
Regards
Azrael Noor
Azrael Noor wrote:
Still you put much light on it
** I was told to use Timer and TimerTask, but i have no reason why to use them, if i have while(true) and i need continue pinging to database to check for requests to process further.
Still i got an idea that while(true) is not bad practice here
Jeff Verdegan wrote:
Azrael Noor wrote:
No, don't do that. Only sleep if you actually want the thread to pause for a fixed amount of time. If you're waiting for some other event in the system, use wait() or join() or the higher level tools in java.util.concurrent.
Steve
Me wrote: I usually do this...
Steve
Steve Luke wrote:I disagree here, as long a the system.out.println("here 1"); represents real code.
Steve Luke wrote:
Me wrote: I usually do this...
Actually, I am not sure I remember ever doing this with sleep... but I do it with basically anything else which can be interrupted. So maybe Jeff's concern is more specific about the use of sleep() in this construct.
Regards
Azrael Noor
Azrael Noor wrote:I wonder if i do not give any SLEEP to thread and continue process it, what is issue with that.
Regards
Azrael Noor
Azrael Noor wrote:actually all 12 threads are polling one database and single table to update their respective status and to pickand process request and almost every thread sleep for 5000 ms.
so as you said we should use sleep else database will kick :P
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime. |