Arduino Mega - Multithreaded (run two loops simultaneously)
You can combine the 2 programs into 1 program.  But when you start wanting to do multiple things at once then you can't have any code that "blocks" and waits to finish before letting the next thing happen.  The Arduino has a single core, it can't do multithreading.  But if you write non-blocking code you can make things appear to happen at the same time.  I imagine the problem with your code now is that you have probably used the delay function.  That function blocks, so nothing else can happen while the delay is running.  Instead you have to use millis to record the time and periodically check against that time to see if it is time to take the next step instead of calling a delay to wait for the next step.  See the "Blink Without Delay" example that comes with the IDE and any of the multitude of tutorials about it on the web to see how it works.