Using AccelStepper library

I am trying to get this to work: AccelStepper: AccelStepper library for Arduino

This version of it is moving to the position, setting a new position, moving to that position… and so on. This is what I expect it would do.

#define pinDir      2 //Pin for setting rotation direction
#define pinStep     4 //Pin for doing the steps

#include <AccelStepper.h>

AccelStepper ARM(1, pinStep, pinDir);

void setup()
{  
  ARM.setMaxSpeed(5000);
  ARM.setAcceleration(65000);
}

void loop()
{  
  ARM.moveTo(random(0,3000));
  ARM.runToPosition();  
}

But as far as I can see in the code it is possible to use just .run() in the loop to make it non-blocking while the stepper is getting to its position.
The code for non-blocking would I expect would look like this, but it does not work as expected, instead it just makes a few steps and never gaining speed.

#define pinDir      2 //Pin for setting rotation direction
#define pinStep     4 //Pin for doing the steps

#include <AccelStepper.h>

AccelStepper ARM(1, pinStep, pinDir);

void setup()
{  
  ARM.setMaxSpeed(5000);
  ARM.setAcceleration(65000);
  ARM.moveTo(random(0,3000));
}

void loop()
{
  ARM.run();
}

Am I trying to do something which is not possible? Not sure what I am doing wrong here.

In your first code, you set a position, go to it, set a position, go to it, etc.

In your second code, you set a position, and head towards it. Once you get there, you never set a new position or move again. Shouldn't you? There are methods to see if you are at the commanded position, so you can tell when to define a new position.

PaulS:
In your first code, you set a position, go to it, set a position, go to it, etc.

In your second code, you set a position, and head towards it. Once you get there, you never set a new position or move again. Shouldn't you? There are methods to see if you are at the commanded position, so you can tell when to define a new position.

The first code is only like that because I got it to work, at first the new position was in setup to just make it move once, when that worked I stepped it up to move to a new position over and over.

With the second code I am still at the stage where I just want it to move to one position before going to the next.