DROP TABLE IF EXISTS test; CREATE TABLE test ( id VARCHAR(50), value VARCHAR(20) ); INSERT INTO test VALUES ('test', 0); #### use warnings; use strict; use DBI; use Parallel::ForkManager; my $dbh = DBI->connect( "dbi:SQLite:dbname=test.db", "", "", {RaiseError => 1} ) or die $DBI::errstr; my $pm = Parallel::ForkManager->new(20); for (1..20){ $pm->start and next; my $interval = $_ / 10; while (1){ dbwrite($dbh, $interval); #print "$interval\n"; } } while(1){ my $sth = $dbh->prepare( "SELECT * FROM test WHERE id=?;" ); $sth->execute('test'); my $val = $sth->fetchrow_hashref()->{value}; #sleep 1; } sub dbwrite { my ($dbh, $interval) = @_; my $sth = $dbh->prepare( 'UPDATE test SET value=? WHERE id="test;"' ); $sth->execute($interval); };