Is it possible to execute a code in runtime when gets updated over the air (OTA)? I would like to build a lib like ArduinoOTA but with no downtime at runtime. To achieve that I am wondering if it is possible to create a simple setup and loop code to


Check for new releases
If we have a new one start download it
As download routine is not finished keep running the current release
When download has finished, swap current release to the new one.
Now the normal routine is running the new release.


I am pretty interested if it is possible to do by myself something like that.

I didn't find any paper or articles similar to this and I don't known if this is a challenge for Arduino scope or C/C++.

Maybe I am saying something bizarre but I have been thinking of save new release into flash memory, point to it and discard the old release from flash memory.
On many Arduinos the processor is only a few dollar part.  You are asking for a feature that only starts appearing on platforms where the processor is over an order of magnitude higher in price.  Further, such inexpensive processors normally run a single program.  Running a sketch while managing a download &amp; update would best be done by two programs existing in an operating system.  Again, likely requiring a processor an order of magnitude higher in price.

Instead, consider implementing your design using two different Arduinos.  Swapping one out for the other after updating.   Hot swapping may not be trivial.  This really depends on how your application interfaces with the world. But likely will be much easier than solving the problem of designing the supporting software to make sketch updates transparent to the Arduino user.