in reply to Re^2: Looping in the background of your main program
in thread Looping in the background of your main program
but still do not understand how to fork a process and use my variables from my main process there aswell
The point is, you can't (directly). At the time of forking, all program data (including variables with their current values) are being duplicated, but from that point onwards, updates to the two copies of the variables do happen independently. It's for that reason that you'd then need IPC.
With threads and threads::shared, OTOH, you can tell Perl which variables you want to share across the different threads. But threads may be problematic in other ways, for example in that code (which you've loaded before creating a new thread) needs to be thread-safe — which in particular external libraries (as often needed with XS modules) sometimes aren't.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Looping in the background of your main program
by dk (Chaplain) on Jan 01, 2010 at 15:05 UTC | |
by pdltiger (Acolyte) on Jan 01, 2010 at 15:47 UTC |