java - My program will be crashed after a few seconds . why? -


This works for a few seconds and will crash suddenly.

  import java.util. *; Import javax.microedition.midlet *; Import javax.microedition.lcdui *; Public Class Canvas Unit Canvas (Private Timer Timer; Private Timer Task Class Function; Private Input Top = 13, Left = 48; Private Input Width = Matching); Private Int Height = Meetings (); Private Static In SWIDTH = 10; Private Static Ent Siege = 10; Private Ent LStep = 5; Private Int TST = 5; Public Canvas Unit (Timer = New Timer); Task = New TimerTask Class (); timer.schedule (Task, 10);} Public Zero Color (Graphics G) {g.setColor (0,0,0); G.fillRect (0, 0, Width, High ); G.setColor (255,255,255); G.drawRect (Left, Top, Swind, Shil);} Private Class Timer Task Class TimerTask {Public Ultimate Zero Run (if (Left> (Width - SWidth)) Expanded {LStep = LStep * (-1);} and if (left & lt; 0) {LStep = Math.abs (LStep);} // if (top & gt; (height - true)) {TStep = TStep * (-1);} and if (top  
  import javax.microedition.lcdui. * Should use something similar to *; Public class canvas unit canvas (Private int Top = 13, Left = 48; Private int width = joining); Private int height = joining (); Private static int SWIDTH = 10; Private static intimate = 10; Private int LStep = 5; Private Ent TST = 5; Public Canvas Unit () {Thread T = New Thread (Public Nilless) {When (True) {If (Left and (Width - SWidth) ()) {LStep = LStep * (-1);} else if (left & lieutenne; 0) {LStep = Math.abs (LStep);} // if (top & gt; (height-wise)) {TStep = TStep * (-1) ;} And if (Head Sh {0} {TStep = Math.abs (TStep);} Left = Left + LStep; Top = Top + TStep; repaint (); {Thread.sleep (10);} Hold (Exception Ex) {}} }}); T.start (); } Public Zero Color (Graphics G) {g.setColor (0, 0, 0); G.fillRect (0, 0, width, height); G. Setler (255, 255, 255); G.drawRect (left, top, swindle, decent); }}    

Comments