thanx for u r response...
i did used
use threads::shared;
 my %bounds : shared = ();

but i didn't use following....

{
         lock(%bounds);
         #-- do something with %bounds
 }

and i got following error while running script...

perl.exe application errorr

The instruction at "0x2808335c" referenced memory at 
"0x00000004". The memory couldn't be written

this error is because of not doing lock
on %bounds ?

when we do the lock like
lock(%bounds)
does it lock all the elements in hash ?

Thanx
Madhu


Thanx
-Madhu






--- david <[EMAIL PROTECTED]> wrote:
> Madhu Reddy wrote:
> 
> > hi,
> >   I just want to find out how and when to use
> locks in
> > threads...
> > i have following program..
> > in following %bounds is global variable....
> > each thread will update %bounds....
> > and later i am using %bounds...
> > 
> > do i have lock the %bounds before each thread
> update ?
> > 
> > 
> > my %bounds = ();
> > 
> > 
> 
> by default, %bounds is not shared among threads
> (local variable is not 
> shared among threads), you have to tell Perl that
> you want to share it 
> like:
> 
> use threads::shared;
> 
> my %bounds : shared = ();
> 
> now that %bounds is shared, you need to lock it when
> you update/access 
> %bounds. again you have to tell Perl that you want
> to lock it like:
> 
> {
>         lock(%bounds);
>         #-- do something with %bounds
> }
> 
> #-- unlock when block exit
> 
> the bare block is important, Perl unlocks %bounds
> automatically when the 
> block exit.
> 
> david
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to