Hi - > -----Original Message----- > From: dan [mailto:[EMAIL PROTECTED]] > Sent: Saturday, February 01, 2003 6:46 AM > To: [EMAIL PROTECTED] > Subject: Threads > > > Hey again, > > I have another problem, this time involving threads. Here's what > I intend to > do, and what I have in code (roughly). > > Basically, I want my program to run normally, but also have a while (1) { > ... } loop going at the same time. This checks for things such as expired > objects. The loop checks to see if $currtime >= $akill{$id}->{expires}, it > does this, but the way I activated the thread, it only does something when > something else happens in the program. > > Code wise, I have: > sub akilltimeout { > while (1) { > # do time checking here > sleep 1; > } > } > > This is executed within another sub by threads, when the program > is ready to > start it, with: > $t = Thread->new(\&akilltimeout); > > I'm using "Thread" not "threads". What am I doing wrong? Is > "threads" better > than "Thread", and will it do what I want it to? > > Many thanks. > > Dan >
Which version of perl are you using? If you are using 5.8 - use 'threads' - that is the new (working) threading model! Your example _should_ then work (with 5.8). You may want to put a: threads->yeild; in the loop. I recommend: 1) upgrade to 5.8 2) read perldoc perlthtut before using threads. Aloha => Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]