Two ice cream machines make a total of 320 gallons in a certain amount of time.

Working together for the same length of time, how many gallons of ice cream can
4 ice cream machines make?

If two ice cream machines make a total of 320 gallons in a certain amount of time, then each ice cream machine makes 320/2 = <<320/2=160>>160 gallons in that time.

Since 4 ice cream machines are twice as many as 2 machines, they will make twice as much ice cream in the same amount of time, so 4 ice cream machines can make 2*320 = <<2*320=640>>640 gallons of ice cream. Answer: \boxed{640}.