When you do not eat, you are not permanently hungry, at least not when you are accustomed to this. This is similarly like when you feel that you must immediately use the restroom, but when that not happens the sensation disappears and it may come back only one hour or two later.
What is funny is that, at least for me, the sensation of hunger is strongly conditioned by whether there really exists a possibility to satisfy it.
I eat 2 meals per day and during the time between them I am not hungry, and if I were hungry that would be futile, because I intentionally do not keep in my home any kind of food that can be eaten instantly, but only raw ingredients that I must cook before eating.
After I cook my next meal, I have to be patient and wait some time for the food to cool down. During that time, I become suddenly very hungry and like you say, I find it difficult to continue to work at the computer or at whatever I was doing, as my thought shifts to the food I am waiting to eat.
In the past, when I kept food that could be eaten at any time, without preparation, I became frequently hungry and it was hard to resist to the temptation of having a snack.
Some people never seem to be able to think clearly or focus while fasting, independently of any feelings of hunger. There is likely some biological variability here, but it could also be due to metabolic problems that are making it hard to provide the brain with energy during a fast. In some cases the fasting itself can help treat that, and it may get better over time.