我有一个 Spring Neo4J 服务器
我希望在此服务器中拥有一个端点,该端点启动一个线程以将 twitterstream 的推文保存到 neo4j 数据库中。
我还希望有一个端点来停止该线程。
最好的方法是通过 TaskExecutor
对象执行此操作,还是应该创建一个 Runnable
对象并将其保存到可以与之交互的服务 bean 中?
如何在 Spring Data 服务器中的 REST API 端点上下文中执行此操作?
最佳答案
The way they recommend is to use a shared variable as a flag which asks the background thread to stop. This variable can then be set by a different object requesting the thread terminate.
关于java - Spring neo4j 启动/停止长时间运行的进程的最佳位置 [Java],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56396450/