Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
timer.scheduleAtFixedRate(() -> sendTimeToAll(session),0,1,TimeUnit.SECONDS);
This expression is used in java 8, how to write this in java 7 version
scheduleAtFixedRate
That looks like a Runnable, so you can implement it as a anonymous inner class.
Runnable
timer.scheduleAtFixedRate(new Runnable() { @Override public void run() { sendTimeToAll(session); } }, 0, 1, TimeUnit.SECONDS);
Add a comment
The lambda () -> sendTimeToAll(session) is nothing more than a direct implementation of the Runnable-interface.
() -> sendTimeToAll(session)
So () -> sendTimeToAll(session) is equivalent to this
new Runnable() { public void run() { sendTimeToAll(session); } }
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
scheduleAtFixedRatemethod expects.