Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Thread execution

 
Anuj Joshi
Greenhorn
Posts: 22
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 47229
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 56
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use java.util.concurrent.CountDownLatch
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If what you are asking is the ability to execute a code after a thread has finished execution, all you need is a join
 
Doua Beri
Ranch Hand
Posts: 60
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic