Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
- @Override
- public void run() {
- doSomething();
- count++;
- if (count <= 3) handler.postDelayed(this, 3000);
- }
- }, 3000);
- myApi
- .getRequestBody()
- .repeatWhen(h-> h.delay(3000L, TimeUnit.MILLISECONDS))
- .takeUntil(stopPolling -> count < 3)
- .subscribe(this::showList);
- final Handler h = new Handler();
- for (int i=1;i<numberOfTimes+1;i++) {
- h.postDelayed(new Runnable() {
- @Override
- public void run() {
- function();
- }
- },i*3000);
- }
- public static void main(String[] args) {
- new Thread() {
- @Override
- public void run() {
- while (true) {
- for (int i = 0; i < 3; i++) {
- ourMethod();
- }
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
- }.start();
- }
- public static void ourMethod() {
- //do smth
- }
Add Comment
Please, Sign In to add comment