The trickiest part is correctly writing the logic that spawns the secondary thread used for heartbeats.