Help with foreach syntax

Looking for some help with a foreach loop. I’m having reliability problems sending x10 commands through mochad. It seems like only the first item in the group is getting the on/off command, which to me points to the service being too busy to keep up. So, I’d like to add a delay between each command. However, the IDE says this is not the correct syntax for the foreach loop:

Holiday_Lights.members.forEach(item |
	Thread::sleep(5000)
	item.sendCommand(ON)	
)

Java is not my first language, but this seems very simple. What am I missing here?

Thanks!

Well, Rules aren’t written in Java so that doesn’t really matter.

You probably have to put the Thread::sleep in a try/catch.

try { Thread::sleep(5000) } catch(InterruptedException e) { }