my $dbh = DBI->connect("dbi:mysql:$db:$host", "$db_user", "$db_password", {RaiseError => 0, PrintError => 0} ) # We do the error check. Maybe we dont wanna die if error! or errTrap("Cannot connect to the database"); threads->create(&dbUpdate()))->join; threads->create(&anotherThread()))->join; sub dbUpdate() { while(1) { do som db stuff when wanted } } sub anotherThread() { do stuff on shared variables that the db uses... }