Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要每 1 秒执行一次块,但它需要在同一个线程中。这意味着,据我了解,我不能使用计时器类。
有没有办法做我想做的事?
创建一个线程并像这样编写一个循环 -
while(true) { // do something Thread.sleep(1000); }