Thank you Nick for your comment. However in the project that I am doing, the timing of the ISR is very critical and I cannot stop it no matter what. Is there any way around that. Is there a way to let the ISR do its job (read sensors to volatile variables (ints)) and these variables can be read in the main loop? ( I am not writing to them, just read them in main loop)
No-one said anything about stopping the ISR. If you have multi-byte variables, then in the
main loop you need to protect them by putting noInterrupts() in front of attempts to access them.
If timing is critical, put all the relevant variables into a struct, and then make a quick copy of it. eg.
myStructType copyOfVariables;
noInterrupts ();
memcpy (©OfVariables, &isrVariables, sizeof copyOfVariables);
interrupts ();
Bear in mind the ISR won't fire immediately, necessarily, anyway. For example, the millis() interrupt may be processing its stuff.