title: Average in RxJava
body: <p>I am trying to make a system resource monitor using Rx. I use a thread for observable which returns the CPU Usage every 1000 milliseconds. Now I want my subscriber to find the average of the CPU usage every 10 seconds.</p>
  
  <pre><code>    public class seperate {
      private ScheduledThreadPoolExecutor executorPool;
      public void test()
     {
  
      Observable&lt;Double&gt; myObservable = Observable.create(
              new Observable.OnSubscribe&lt;Double&gt;() {
                  @Override
                  public void call(Subscriber&lt;? super Double&gt; sub) {
                      executorPool = new ScheduledThreadPoolExecutor(9);
                      int timeout1 = 10;
                      TimerTask timeoutTimertask1=new MyTimerTasks(sub);
                      executorPool.scheduleAtFixedRate(timeoutTimertask1,timeout1, timeout1,
                          TimeUnit.MILLISECONDS);
                      // This returns the cpu usage every 10ms.                      
  
                  }
              }
          );
      Subscriber&lt;Double&gt; mySubscriber = new Subscriber&lt;Double&gt;() {
          @Override
          public void onNext(Double s) { System.out.println(s); }
  
          @Override
          public void onCompleted() { }
  
          @Override
          public void onError(Throwable e) { }
      };
      myObservable.subscribe(mySubscriber);
  
  }
  </code></pre>
  
  <p>}</p>