#!/usr/bin/env perl use Data::Dumper; use threads; use Thread::Queue::Any; use strict; use warnings; my $thread_queue = Thread::Queue::Any->new; async { \&testThread($thread_queue) }; async { \&_thread_for_images($thread_queue) }; while (1) { sleep 1; } sub testThread { my $queue = shift; while (1) { $queue->enqueue("something"); sleep 2; } } sub _thread_for_images { my $queue = shift; my $pid; while (1) { my ($full_path) = $thread_queue->dequeue; print $full_path . "\n"; sleep 2; #if ($oid) { # print "KILL!\n"; # $oid->kill(); #} #sleep 2; $pid = fork(); if ($pid) { print "Parent\n"; waitpid($pid,0); } elsif (defined ($pid)) { print "Child\n"; &mainloop2(); exit; } #$app->MainLoop; } } sub mainloop2 { if (-e "imageHandling.pl") { my $app = do "imageHandling.pl"; if (!defined($app)) { die "imageHandling not loaded.\n"; } } else { print "imageHandling.pl not found.\n"; exit; } my $app = MyApp->new(); # create $app->newImageFrame("L:/02.jpg", 200, 500); $app->newImageFrame("I:/34.jpg", 400, 500); #print Dumper($app); $app->MainLoop; $app->Destroy; }