Sounds like you are using multiple processes, not Threads; 2 different things.
In that case, you could just use a hash in the master process to keep a list of current logins. However, you'd have to find a method for the client procs to communicate back when they're done, so releasing that entry.
Methods include writing to a file (can be tricky), 1 table DB (handles locking for you), shared mem, etc.
For lock files, I use bare bones code
Code:
use Fcntl qw(:flock);
open(LOG) or (error handler)
flock(LOG, LOCK_EX) or
flock(LOG, LOCK_UN) or ..
close(LOG) or ...
Strictly speaking you only need a LOCK_EX for writing (& will block until other writer process with LOCK_EX lets go), LOCK_SH will do for read-only without blocking eg 'test if login in this file' only requires read access.
http://perldoc.perl.org/
http://www.perlmonks.org/?node=Tutorials
Threads are useful for co-operating 'processes' (ie threads not forked processes), but hard to learn first time around.
Have a look at Chap 16.19 in Perl Cookbook (worth its weight in gold imho) for uses of wait(), waitpid() and also those links, as another option.