Skip to content

Tips: running a thread in parallel to serverino

Andrea Fontana edited this page May 28, 2023 · 1 revision

@onDaemonStart and @onDaemonStop allow you to run code when serverino is started and stopped.

@onDaemonStart void mywork()
{
	// You should create a new thread otherwise you're blocking serverino :)
	new Thread({ 
		// isDaemon = true to kill this thread when serverino exits.
		Thread.getThis().isDaemon = true;
		while(true)
		{
			info("Running!");
			Thread.sleep(1.seconds);
		}
	}).start();
}