Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / November 2005

Tip: Looking for answers? Try searching our database.

Monitor problem

Thread view: 
Marcelo - 10 Nov 2005 23:35 GMT
Hello,

I have a problem with a Monitor implementation. I would like to have a
linkedList with many threads inside (for dumping Images from urls).

However, whenever I launch many threads in parallel I get an out of
Memory problem (which is normal because of the size of the images I
suppose...).

I would like to launch 10-15 threads in parellel and then let the other
threads to just wait in the linked list.

while(condition to only have 10-15 threads){
    get Element from list
    launch thread   
}

However, i just don't know when my threads finish. How can I do it?
Do you have an idea?

thank you very much for your help,

Marcelo
dwalter - 11 Nov 2005 17:06 GMT
simple in your class with the will loop (called class A for now.) you
have an declaration like this: private int threadsRunning =0; and 2
synchronized functions:

public synchronized void void startThread() {
     threadsRunning++;
}

public synchronized void void endThread() {
     threadsRunning--;
}

and you have your threads call endThread when they end and call
startThread as you start.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.