Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-17-2008, 08:05 AM
Member
 
Join Date: Oct 2008
Posts: 4
Rep Power: 0
thangbomlennet is on a distinguished road
Default about array Thread
exp, i create array nameThread tpye class DownloadThread

DownloadThread[] nameThread = new DownloadThread[100];
for(int i=0;i<100;i++)
nameThread[i] = new DownloadThread(strUrl);

now,I don't know ..how to know all Threads run finished.
plz help me.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 12-18-2008, 04:13 PM
Senior Member
 
Join Date: Nov 2008
Posts: 265
Rep Power: 1
neilcoffey is on a distinguished road
Default
You can use the CountDownLatch class. The idea is that you create a CountDownLatch with the number of threads you'll have, then waiting on this latch (note "await", not "wait"!):

Code:
CountDownLatch latch = new CountDownLatch(100);
// ... create threads, passing them 'latch', and start them
latch.await();
Then, each thread ends by counting down the latch:

Code:
// thread's run method
public void run() {
  try {
    // ... do exciting thing
  } finally {
    latch.countDown();
  }
}
__________________
Neil Coffey

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Difference between Thread.yield() and Thread.sleep() methods Nageswara Rao Mothukuri New To Java 9 11-11-2008 02:51 PM
passing a value from parent thread to child thread sachinj13 Threads and Synchronization 7 09-07-2008 09:06 PM
data from the main/GUI thread to another runnin thread... cornercuttin Threads and Synchronization 2 04-23-2008 10:30 PM
If JNI thread call the java object in another thread, it will crash. skaterxu Advanced Java 0 01-28-2008 07:02 AM
Creating a Thread (extending Java Thread Class) JavaForums Java Blogs 0 12-19-2007 09:31 AM


All times are GMT +2. The time now is 12:35 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org