This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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 OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 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 -
I agree. Here's the link:
subject: how to stop a thread in j2me
It's not a secret anymore!