in reply to Re^4: Semaphores failing to prevent race condition
in thread Semaphores failing to prevent race condition

Requiring a module in one thread loads it for the entire process.

The script below traces out the content of %INC (as proof of what is loaded) three times.

  1. Once in main before a thread requires Tk.

    No Tk is visible to the main thread.

  2. Once in the thread after it has required Tk.

    The Tk modules are now visible. Within the thread.

  3. Once again in main after the thread has required Tk.

    The Tk modules remain invisible to the main thread.

Ergo. Anonymonk is right. You are wrong.

Live with it but don't talk about it cos no one is interested in how you are going to try to justify not just a wrong statement, but one where you tell someone who is so obviously correct, that they are wrong.

The oh so complicated test code:

#! perl -slw use strict; use threads; async{ sleep 4; require Tk; print for '2 ', keys %INC; }->detach; sleep 2; print for '1 ', keys %INC; sleep 6; print for '3 ', keys %INC;

And the proof:

C:\test>junk 1 XSLoader.pm warnings/register.pm strict.pm C:/Perl64/site/lib/sitecustomize.pl warnings.pm threads.pm overload.pm Config.pm 2 re.pm C:/Perl64/site/lib/sitecustomize.pl ActiveState/Path.pm Cwd.pm warnings.pm Tk/Wm.pm Symbol.pm C:/Perl64/site/lib/auto/Tk/getEncoding.al Exporter.pm Encode/Unicode.pm C:/Perl64/site/lib/auto/Tk/autosplit.ix Tk/Toplevel.pm File/Spec.pm File/Spec/Win32.pm Encode/Byte.pm warnings/register.pm XSLoader.pm Encode/Alias.pm Tk/Frame.pm Encode/Config.pm C:/Perl64/site/lib/auto/Tk/Toplevel/autosplit.ix Encode/Encoding.pm Tk/Pretty.pm Tk/Widget.pm Config_git.pl threads.pm base.pm Encode.pm C:/Perl64/site/lib/auto/Tk/Wm/autosplit.ix Tk/MainWindow.pm Tk/Submethods.pm Config.pm File/Basename.pm ActivePerl/Config.pm C:/Perl64/site/lib/auto/Tk/Widget/autosplit.ix Tk/Image.pm Carp.pm Tk/Event.pm bytes.pm File/Spec/Unix.pm Tk/Event/IO.pm vars.pm strict.pm Tk/Derived.pm constant.pm C:/Perl64/site/lib/auto/Tk/Frame/autosplit.ix Config_heavy.pl Tk/Configure.pm Tk/After.pm overload.pm AutoLoader.pm Tk/CmdLine.pm DynaLoader.pm Tk.pm 3 XSLoader.pm warnings/register.pm strict.pm C:/Perl64/site/lib/sitecustomize.pl warnings.pm threads.pm overload.pm Config.pm

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.