[英]twitter4j: Running in asynchrounous mode
i have list of twitter user ids in a file. 我在文件中有Twitter用户ID列表。 And i am required to collect tweets of all the users in that file. 而且我需要收集该文件中所有用户的推文。 Currently i am able to fetch tweets of all users. 目前,我能够获取所有用户的推文。 But i need to run is code forever. 但是我需要永远运行代码。 Currently i am doing something like this 目前我正在做这样的事情
while(true) //run forever
{
open(user ids file);
while(there is more ids in file)
{
long id = readIDFromFile(file);
List<Status> statuses = getTweetsForUser(id);
appendListToTweetFile(statuses);
}
close(user ids file);
}
The reason i want to run it forever so that if there is any new tweet posted by any user i am able to record it. 我想永远运行它的原因是,以便如果有任何用户发布任何新的推文,我可以将其记录下来。 My question is is there a better way to run this code forever, I know keeping the code in infinite loop is not a good idea!!! 我的问题是有没有更好的方法可以永远运行此代码,我知道将代码保持无限循环不是一个好主意!!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.