Mark Murphy wrote:
> Ben Williamson wrote:
>    
>> I think a better way to have phrased my question is....
>>
>> "public final void suspend()
>> This method is deprecated. May cause deadlocks."
>>
>> is in the javadoc for the Thread class....
>>      
>
> Yes. It's been deprecated for over a decade, including "traditional"
> Java since at least Java 1.4, and perhaps earlier.
>
>    
>> is there an alternative to
>> this method so I do not have to kill and completly start over each time
>> I need to pause my activity.
>>      
>
> I don't know anything about your application. As such, it is very
> difficult to provide specific advice, since there are many patterns for
> Java concurrency.
>
> IMHO, threads should be totally disposable. You should be able to signal
> your threads to shut down, and they should shut down of their own accord
> quickly. Whether you use an a LinkedBlockingQueue or a Semaphore or
> whatever for the signaling is more a question of how you are organizing
> the work in the background threads.
>
> The key is for the threads to be disposable, but for those threads to be
> able to pick up where the others left off when the activity is resumed.
> Then "start[ing] over each time" doesn't happen, as far as work is
> concerned.
>
> This means that threads should not hold state. My personal preference is
> the job queue pattern: threads pull jobs off a LinkedBlockingQueue,
> block on the queue if the queue is empty, and exit the queue-blocking
> loop if they get a "kill job" off the queue. The jobs hold state for
> what needs to be done.
>
>    
I sense a bit of sarcasm in the first part, I know they have been 
depricated, but I don't work with threads much and I've never needed to 
pause one (but throwing in Android's activity structure brings up that 
need).

What you explained about the job queue makes much more sense than what I 
was trying accomplish. Sometimes you just need someone to bounce off of, 
sorry if I _annoyed_ you with my ignorance :). I'm no longer ignorant on 
the matter thanks to yourself!

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to android-beginners@googlegroups.com
To unsubscribe from this group, send email to
android-beginners-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to