Grails,Thread.start{…}无法从BootStrap.groovy运行
我在BootStrap.groovy中运行以下代码:Grails,Thread.start{…}无法从BootStrap.groovy运行,grails,groovy,Grails,Groovy,我在BootStrap.groovy中运行以下代码: if (Core.isDevelopment()) { File file = Core.getWebappFile("${App.files.root}App/styles/empty.less"); if (file && file.exists() ) { Core.Log.println(
if (Core.isDevelopment()) {
File file = Core.getWebappFile("${App.files.root}App/styles/empty.less");
if (file && file.exists() ) {
Core.Log.println('File exists')
def thread = Thread.start {
Core.Log.println('Thread append')
file << ' ';
sleep( App.lessRefresh );
}
}
}
if(Core.isDevelopment()){
File File=Core.getWebappFile(“${App.files.root}App/styles/empty.less”);
if(file&&file.exists()){
Core.Log.println('文件存在')
def thread=thread.start{
Core.Log.println('Thread append')
文件如果它打印“线程附加”,它就工作了…你还期望什么?它只打印一次。它不应该每700毫秒打印一次(App.lessRefresh=700)?不是没有循环的…因为你有它,它会打印、睡眠,然后完成嗯…我想这已经解决了…所以虽然(真的)安全使用吗?是的,但是你最好使用一个或石英插件来安排每n毫秒运行一次任务