Run() method don?t do nothing

November 30 0
Advertisement
I create a thread object and call to the star() method, but the run() source is not executed, althougt the console say that there 2 thread running. Can some body what is heppening? I?m sorry of my english
Advertisement
this class is used by a J2ME app:
package ejemplo1.guardar;
import java.io.*;
import javax.microedition.io.*;
* @author ocriv
public class Comunicacion implements Runnable{
private Thread t;
private String respuesta;
private HttpConnection c;
private String url;
/** Creates a new instance of Comunicacion */
public Comunicacion() {
respuesta = null;
public void Conectar(String str){
url = str;
t = new java.lang.Thread();
t.start();
public void run(){
try{
c = (HttpConnection) Connector.open(url);
c.setRequestMethod(HttpsConnection.GET);
InputStream is = c.openInputStream();
procesarRespuesta(c,is);
System.out.println("FUNCIONA");
catch (Exception e){
System.out.println(e);
void procesarRespuesta(HttpConnection http, InputStream inst) throws IOException{
if (http.getResponseCode() == HttpConnection.HTTP_OK){
int lon = (int) http.getLength();
if (lon != -1) {
byte datos[] = new byte[lon];
inst.read(datos,0, datos.length);
respuesta = new String(datos);
else {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int ch;
while ((ch = inst.read()) != -1){
baos.write(ch);
respuesta = new String(baos.toByteArray());
baos.close();
else {
System.out.println(http.getResponseMessage());
public String getRespuesta(){
return respuesta;
}
How can I kill all Threads of the same class from within the run() method?

Ok I have a class called Consumer that extends Thread I have several Consumer threans running... but, when a certain condition is true (within the run() method) in ANY of the threads, I want to kill ALL the threads of that object. is this possible?I

How to get value from Thread Run Method

I want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that it seems that scope of t

Unsatisfied link when callind dll from run method Help Please?

Hi, I get an unsatisfied link error while trying to calling a dll at a certain time period in a run method. The same dll works fine called in another setup and even called in a loop. Can anyone help please? import java.util.Timer; import java.util.Ti

How to throw exception in run() method of Runnable?

Hi, everyone: I want to know how to throw exception in run() method of interface Runnable. Since there is no throwable exception declared in run() method of interface Runnable in Java API specification. Thanks in advance, GeorgeThanks, jfbriere. I mu

How can I get the variable with the value from Thread Run method?

We want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that scope of the variable g

How can I get the variable with the value from Thread's run method

We want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that scope of the variable g

How to throw Exception in Thread.run() method

I want to throw exception in Thread.run() method. How can I do that ? If I try to compile the Code given below, it does not allow me to compile : public class ThreadTest {      public static void main(String[] args) {      ThreadTest.DyingThread t =

Passing parameters to run() method of a thread?

hello ppl is it possible to pass any parameters to the run() method of a thread moreover if i create a thread foo the only method that can run is run() ? i know that i can have more methods and just call them via run(). i mean that if i create the co

When we create JDialog inside Thread's run() method it is creating problem

I have application that has feature that mainframe will be locked after three minutes and the time when it is locked it will show other locked dialog. Now my problem is given below: I have created one Dialog inside Threads run() method and this threa

Stopping a Thread (no control on run method)

Hi, How can we stop a Thread like in the following scenario. If we are in the aMethod() and the stopped variable is set to true by some other thread now how can we return from this run method and stop executing the aMethod(). Any tips are helpful. pu

Resource registration is failing - Couldnt run method tag. Error in execve

Hi, We have solaris cluster setup with two nodes and a resource group exists which contains a zfs resource which could be mounted on to one of the nodes in the cluster. Our application is installed on one of the directory in the zfs file system. The

How to use run() method in serlvets

Hi, I want to execute run() method in servlet as i have got a web application where in I want to set timer for the choosen times and want to pop up when ever the time elapses..can anybody help Thanks, veni..The API documentation has a link at the top

Overload run method

Hi all, is it possible to overload the run method of a Thread. Thank You PanikiranBased on your question, I have a sneaking suspicion that you believe an overloading method is somehow related to the overloaded method in a way other than just happenin

Is it possible to throw an exception from run method of a thread?

Is it possible to throw an exception from "run method of a thread"(implemented as runnable implementation)? Is it advisable to do so?Is it possible to throw an exception from "run method of a thread"(implemented as runnable implementat

Thread.run() method..

I was wondering how the "Thread.run()" method get called. I started with "Thread.start()" and found it calls the "Thread.start0()" which is a native method. I downloaded the JDK 5 source code and went to "j2se\src\share\

Run() method in Thread.

Hi, why we not declare run() method synchronized ? if we do so , then what happen ? Thanks in advance ...user13484853 wrote: EJP wrote: What is synchronization, synchronization method, synchronization blockThis page is complete drivel. There were err

Run method in Thread subclass

run method of Base calss is executing when I run this code. If I remove Base.run() it Test1.run() is getting executed. can anybody explain why.? class Base extends Thread{ public native String getTime();      Base(Runnable r)           super(r);     

Calling run method

Hi frnds, Why do we need to call thread.start() to execute a thread. why not just calling run().run() is just a method... you need new Thread object to start a new thread... you can pass any Runnable object ( any class that implements the Runnable in

Thread's run method

I cannot unserstand why the output of this program is: axa axa class A extends Thread public void run() System.out.print("axa "); public class Main public static void main(String[] args) throws Exception Thread t = new Thread(new A()); t.run();

How run method is called in a thread

Hello, If I call start method of a thread, then I want to know if run method is automatically called or not. Thank youA tutorial on threads would doubtlessly contain much of the information you're after. There might be something in the Java Tutorial