Not exactly. attributes says:
locked

Setting this attribute is only meaningful when the subroutine or method is to be called by multiple threads. When set on a method subroutine (i.e., one marked with the method attribute below), Perl ensures that any invocation of it implicitly locks its first argument before execution. When set on a non-method subroutine, Perl ensures that a lock is taken on the subroutine itself before execution. The semantics of the lock are exactly those of one explicitly taken with the lock operator immediately after the subroutine is entered.

And that's basically what happens (i think you misunderstand what locking does).
#!/usr/bin/perl -w -l -- @ARGV = qw[ foo bar baz ]; use threads; $|=1; sub f :locked { my $tid = threads->self()->tid(); print "A}$tid}$_[0]"; select undef, undef, undef, rand(2); print "B}$tid}$_[0]"; } threads->create(\&f, $_) for @ARGV; $_->join() for threads->list() __END__ A}1}foo A}2}bar A}3}baz B}3}baz B}2}bar B}1}foo #!/usr/bin/perl -w -l -- @ARGV = qw[ foo bar baz ]; use threads; $|=1; sub f :locked { my $tid = threads->self()->tid(); print "A}$tid}$_[0]"; select undef, undef, undef, rand(2); print "B}$tid}$_[0]"; } threads->create(\&f, $_) for @ARGV; $_->join() for threads->list() __END__ A}1}foo A}2}bar A}3}baz B}1}foo B}2}bar B}3}baz

MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
** The third rule of perl club is a statement of fact: pod is sexy.


In reply to Re: (ithreads) :locked subs by PodMaster
in thread (ithreads) :locked subs by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.