Results 1 to 3 of 3
Thread: What's the point of try {} ?
- 08-05-2011, 02:06 PM #1
What's the point of try {} ?
Hello. I was looking at a tutorial talking about multi-threads, and they used this example to explain the subject:
Java Code:/** * Applet MostrarCadena * * <APPLET CODE="MostrarCadena.class" WIDTH="200" HEIGHT="70"> * <PARAM NAME="Cadena" VALUE="Esto sí que es chulo"> * </APPLET> */ import java.applet.Applet; import java.awt.*; public class MostrarCadena extends Applet implements Runnable { String mensaje; int lugar; Thread hilo = null; public void init() { mensaje = getParameter("cadena"); if (mensaje==null) mensaje = "Mensaje por defecto"; lugar = getBounds().width; } public void start() { if (hilo==null) { hilo = new Thread(this); hilo.start(); } } public void stop() { hilo = null; } public void paint(Graphics g) { g.drawString(mensaje,lugar,20); } public void run() { while (hilo!=null && hilo.isAlive()) { lugar -= 1; repaint(); catch (InterruptedException e) {} // No hacemos nada } } }
Java Code:try { hilo.sleep(10); }
In fact, I think that I don't even know what's try{} for. I'd like someone to explain me what's its function.
THANKS.
- 08-05-2011, 02:33 PM #2
- 08-05-2011, 02:47 PM #3
Similar Threads
-
What is the point of Interfaces?
By minime12358 in forum New To JavaReplies: 9Last Post: 09-02-2010, 03:24 PM -
looking for Point interpolater
By gib65 in forum AWT / SwingReplies: 5Last Post: 08-20-2010, 05:22 PM -
Access Point
By ja107 in forum NetworkingReplies: 0Last Post: 03-05-2010, 06:59 PM -
Can someone point me to an example?
By smhjr in forum New To JavaReplies: 2Last Post: 08-28-2009, 12:38 AM
Bookmarks