This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Threads and Synchronization and the fly likes Thread execution Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Threads and Synchronization
Bookmark "Thread execution" Watch "Thread execution" New topic
Author

Thread execution

Anuj Joshi
Greenhorn

Joined: Feb 05, 2009
Posts: 22
Hi..

I have written a code in a thread & need to execute this code completely & then it should execute code outside the thread.

what I want the execution of the below code(i.e. code-2) should be executed after thread. how can I do this??






Please reply soon
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38033
    
  22
Please be careful which forum you post in. I am sure Rob and Maneesh won't mind if I move this thread.
Your code is very difficult to read; you would do better to post an SSCCE.
Vivek Kr Singh
Ranch Hand

Joined: Oct 12, 2007
Posts: 56
You can use java.util.concurrent.CountDownLatch


SCJP 1.4
Nitesh Kant
Bartender

Joined: Feb 25, 2007
Posts: 1638

If what you are asking is the ability to execute a code after a thread has finished execution, all you need is a join


apigee, a better way to API!
Doua Beri
Ranch Hand

Joined: Sep 24, 2009
Posts: 60
I'm not sure if I understand the question but if you want a certain code to be executed after a certain thread finish executing his task you should use a ThreadPoolExecutor and rewrite the afterExecute method . hope this helps
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Thread execution
 
Similar Threads
COnfusion About Unreachable Code
Wait and notify
Question about Thread
Mughal, review question 9.6, p.282 (Synchronization)
Progressbar is not showing when downloading file from a given location