How do I do this?
include Java
Thread.currentThread.sleep 3
I saw a posting from several years ago but it did not directly answer the question.
thx
How do I do this?
include Java
Thread.currentThread.sleep 3
I saw a posting from several years ago but it did not directly answer the question.
thx
Either:
Java::JavaLang::Thread::sleep 3
or
Java::JavaLang::Thread.sleep 3
(Note that the static call sleep() on Thread causes the current thread to sleep, so no need to call currentThread()
, and that sleep time is in millisecond).
Here is an example (if you use JRuby prior to 1.7, you will need to add require 'java'
):
t = Java::JavaLang::Thread.new do
puts "Hi."
Java::JavaLang::Thread::sleep 3000
puts "Done."
end
t.start