[Pharo-dev] Multithreading

Camillo Bruni camillobruni at gmail.com
Thu Nov 21 10:07:37 EST 2013


On 2013-11-21, at 15:56, Yuriy Tymchuk <yuriy.tymchuk at me.com> wrote:

> 
> On 20 Nov 2013, at 20:58, Clément Bera <bera.clement at gmail.com> wrote:
> 
>> So what you are looking for is Process and semaphores. 
>> 
>> This is not multithreading in the default Pharo VM + image, currently our semaphore/process management is not multithreaded, but executes all the process in the same thread. What happens basically is that you will run several processes in 1 thread with different priorities, and processes with highest priorities will be executed first. This is very good for your case, because if you put your task in another process with lower priority than the UI process, each time you will trigger a UI interaction the secondary process will be temporarily stopped to execute your UI interaction.
>> 
>> (see #forkAt: Process userBackgroundPriority)
> 
> One more thing: how do I synchronise? For example I want two async processes, but when they both finish I want to execute something. Eg. return merged data generated by processes.

Semaphores are your friends:

semaphore := Semaphore new.

[ ... First Job ...
	semaphore signal. ] fork.

[ ... Second Job ...
	semaphore signal. ] fork.

"consume to signals, aka. pause this thread until both jobs have finished"
semaphore wait; wait. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 447 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.pharo.org/pipermail/pharo-dev_lists.pharo.org/attachments/20131121/fef13edc/attachment.asc>


More information about the Pharo-dev mailing list