search

Home  >  Q&A  >  body text

java - Quartz执行定时job后如何将结果返回?

用Quartz做定时任务调度

需求是这样的,以整点时间戳为文件名,每隔一小时创建一个文件,在这一小时内不断的写文件,达到下一小时关闭当前文件句柄和流,并以当前整点小时创建新文件

现在可以用JobDataMap将数据传入execute方法,可是在execute中创建文件后,文件句柄和流如何传出,可供读写线程再次操作?

求高人解答!

PHPzPHPz2770 days ago995

reply all(1)I'll reply

  • 阿神

    阿神2017-04-18 09:44:27

    Write a singleton service class. The service class has two member variables, one is the file handle and the other is the stream, which can be get and set. Use it as a bean of spring, and inject this bean into both quartz and your reading and writing threads. In quartz, set is used to change handles and streams, and read and write threads use get to read

    reply
    0
  • Cancelreply