#This is the SWIG generated module to my C library use MyModule; #shared scalar $cb_done = 0; #This cb would be invoked by the cloned interpreter in the #C library. This works fine. sub cb_one { ($event, $pdata) = @_; #This line is printed. print "event : ", $event, "\n"; $cb_done = 1; } $status = MyModule::RegisterCB(\&main::cb_one); do { sleep (5); } until ($cb_done == 1) #This line is not printed as $cb_done never becomes 1 #in the main of the perl script print "CB was invoked : $cb_done\n"; #### use threads; use threads::shared; use MyModule; #shared scalar $cb_done : shared = 0;