Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Regular Contributor
n2v2rda2
Posts: 70
Registered: ‎04-14-2010
My Carrier: new
Accepted Solution

thread problem

thanks to you all , i can step vy step

 

as last my post

i want to get image from server

simply, i just tested 17times loop

 

 

while( i++ < 17)

{

Field imageField = new WebBitmapField(url)
//Coderholic - Blackberry WebBitmapField
add(imageField);


}

it returned : too many thread errror

finally i  found "A single application can create up to 16 threads."

 

 

 

where should i turn off thread  in webBitmapField

 

 

 

 

Please use plain text.
Developer
Ted_Hopp
Posts: 1,305
Registered: ‎01-21-2009

Re: thread problem

That class creates, for each field, a new Thread that does not exit until the image is downloaded or it encounters an error. You can't "turn off" the thread. Assuming that you are starting your loop with i==0, the problem is that you are creating 17 WebBitmapFields, and hence too many Threads, basically all at once.

 

I'd suggest that you write your own worker Thread that will load the images one after the other. Once finished, it can call back to the event thread with a Runnable to create normal BitmapFields using the (now-loaded) images. (Alternatively, it can do that for each image as it comes in.) You can use pieces of the WebBitmapField code as patterns for your own thread. (After all, Coderholic writes, "Feel free to use it," so go for it! :smileyhappy:)




Solved? click "Accept as solution". Helpful? give kudos by clicking on the star.
Please use plain text.