Thunder and lightning happen at the same time. The reason they are experienced at different times is because light travels at 300,000 metres a second, while sound only travels at 340 metres a second. You see the light almost as soon as it happens, but the sound takes a little longer to travel trhough the air to meet you - it take around five seconds to travel a mile. So, yes, by counting carefully, you can estimate how far away a storm is.