They can ask each other. The question doesn't say anything to the contrary.
Obviously then it won't be interesting or mathematical.
So, let's say that they are not allowed verbal or non-verbal communication among themselves.
If there's no further information, and if this is a game that's played just once, then the strategy is based on strength in numbers.
If each of them tosses a coin (say black for heads and white for tails) to guess the color of his/her hat, then over a large enough sample, one would expect about 50% of them to get out. This is our baseline scenario.
But there's a better way.
They should count the total number of hats of each color, and guess that their hat is the same color as the majority. It's not a coin toss.
Let's take an example.
Let's say there are 100 prisoners. You are one of them. You can see everyone's hat but yours.
You see 70 black hats, 29 white ones.
This means that if you are wearing a black hat it is one of 71, i.e. your probability of getting a black hat is 71/100.
If you are wearing a white hat then it is one of 30, i.e. your probability of getting a white hat is 30/100.
You should guess your hat is black.
If all prisoners apply this strategy then all those wearing majority-colored hats can get out. (in our case either 70 or 71 as the case may be..which is much better than 50)
Now, let's say the number of prisoners is odd (say 101), and the visible hats are evenly distributed (50 black, 50 white), then you could choose either (or toss a coin) and end up no worse than you would if you were to indiscriminately toss a coin.