Hello everyone, I looked at the article on Habré ( http://habrahabr.ru/post/136802 ) about creating a simple game and decided to borrow some of the code associated with Enemy, which moves towards the player. I rewrote everything correctly, but the enemies in my case do not appear every n-seconds, but simply continuously create and fill the playing field. How is it possible to make the timer work normally and the enemies appear not without fail but with a certain interval. what is up on the playing field (Play - the enemy) 
public class GamePanel extends SurfaceView implements SurfaceHolder.Callback, Runnable { public static final int WIDTH = 856; public static final int HEIGHT = 480; private float coordY = 480; private MainThread thread; private Thread thred = new Thread(this); private Background bg; public static Bitmap rocket; private Bitmap rocket2; private Paint paint; private List<Asteroids> asteroids = new ArrayList<Asteroids>(); Bitmap ast; Timer timer = new Timer(); TimerTask timerTask; Timer timer2 = new Timer(); TimerTask timerTask2; public void draw(Canvas canvas) { final float scaleFactorX = getWidth() / WIDTH; final float scaleFactorY = getHeight() / HEIGHT; if (canvas != null) { final int savedState = canvas.save(); canvas.scale(scaleFactorX, scaleFactorY); bg.draw(canvas); canvas.drawBitmap(rocket2, 0, coordY / 2, paint); Iterator<Asteroids> i = asteroids.iterator(); while(i.hasNext()) { Asteroids e = i.next(); if( ex <= 1000) { e.onDraw(canvas); } else { i.remove(); } } canvas.restoreToCount(savedState); } } @Override public void run() { while(true) { Random rnd = new Random(); try { Thread.sleep(rnd.nextInt(2000)); asteroids.add(new Asteroids(this, ast)); } catch (InterruptedException e) { e.printStackTrace(); } } } public void update() { ast = BitmapFactory.decodeResource(getResources(), R.drawable.play); asteroids.add(new Asteroids(this, ast)); bg.update(); }