File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java Micro Edition and the fly likes how to stop a thread in j2me Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "how to stop a thread in j2me" Watch "how to stop a thread in j2me" New topic

how to stop a thread in j2me

amal shah
Ranch Hand

Joined: May 05, 2006
Posts: 92
my aim is to get an image from the server...
this is how i do it:
public void getimage(String url) throws IOException
HttpConnection conn = null;
InputStream is = null;
int read=-1;
StringBuffer b=null;
conn = (HttpConnection);
is = conn.openInputStream();
b = new StringBuffer();
while ((read =>=0)
catch(SecurityException e)
catch(Exception e)
if (is != null)
if (conn != null)

now what i do get an image i start a Thread...
now the thread has already started...and say for example the user wants to stop the process of getting the current image...and wants to download another the thread will start such a case i would like the earlier process of getting the image to stop....but am not able to get through...

help appreciated

amal shah
Rashid Mayes
Ranch Hand

Joined: Jan 11, 2006
Posts: 160
well you are not supposed to use stop in SE either. To answer you question, you will have to implement the shutdown process yourself.

Try reading this article.

It should give you everything that you need.

Also please review you code and how you are reading from the stream. In addition please see the ByteArrayOutputStream. There is also a method to create an image from a stream.

Rashid Mayes -
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: how to stop a thread in j2me
It's not a secret anymore!