The Artima Developer Community
Sponsored Link

Java Answers Forum
pass parameter between two threads???

3 replies on 1 page. Most recent reply: Apr 10, 2008 1:35 PM by Vijay Kandy

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 3 replies on 1 page
aardra p

Posts: 8
Nickname: aardra
Registered: Apr, 2006

pass parameter between two threads??? Posted: Apr 26, 2006 4:12 AM
Reply to this message Reply
Advertisement
how can we pass parameter between 2 threads?i have to pass one parameter from parent thread to clid thread...how can we do that.....


Swati Sharma

Posts: 1
Nickname: swatirs
Registered: Apr, 2008

Re: pass parameter between two threads??? Posted: Apr 3, 2008 2:33 AM
Reply to this message Reply
hi....

Can you please do tell me the solution you opted for this problem. Because i am encountering the same problem..

thanks in advance

istiaq sh

Posts: 3
Nickname: tryq
Registered: Oct, 2007

Re: pass parameter between two threads??? Posted: Apr 3, 2008 9:44 PM
Reply to this message Reply
I think, u can try using pipe io stream for passing parameters among threads.

Thanks,
Guddu
http://freesourceutilityhelp.googlepages.com

Vijay Kandy

Posts: 37
Nickname: vijaykandy
Registered: Jan, 2007

Re: pass parameter between two threads??? Posted: Apr 10, 2008 1:35 PM
Reply to this message Reply
Create a class (call it Shared) that both threads can use. Use an instance of this class to pass messages between the two threads. You'll need to use wait() and notify() to synchronize accesses. Here's a good example of how you achieve this: http://java.sun.com/docs/books/tutorial/essential/concurrency/guardmeth.html

Don't forget to use volatile on the shared variable. See the dangers of not using volatile here http://www.vijaykandy.com/archives/10

Alternatively you can use a BlockingQueue class like PriorityBlockingQueue(http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/PriorityBlockingQueue.html)

Flat View: This topic has 3 replies on 1 page
Topic: SSL connection between standalone program to EJB on an application server Previous Topic   Next Topic Topic: Size of files in Java

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use