#! /usr/bin/perl use strict; use warnings; my $libPath; use threads; use threads::shared; my %share_threads; share (%share_threads); my $thread1 = threads->create(\&readWrite); my $thread2 = threads->create(\&isPollable); $thread1->join(); $thread2->join(); sub readWrite { # thread started $share_threads{threads->self->tid()} = 1; my $i=0; //Read and Write while ( $i<=10000) { print "==\n"; $i++; } # thread ended $share_threads{threads->self->tid()} = 0; } sub isPollable { print "Thread2 started\n"; # Polling while ( $share_threads{$thread1->tid()} ) { print "#"; } }