wood burning stoves 2.0*
The moose likes Threads and Synchronization and the fly likes threads concurrency problem 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 "threads concurrency problem " Watch "threads concurrency problem " New topic

threads concurrency problem

naved momin
Ranch Hand

Joined: Jul 03, 2011
Posts: 688

i have code a chat server and a client with 2 threads in each in server and 2 for client
1 thread will start writing and other thread of client will start listening to the server thread
when this both threads finish the two other thread comes into picture
where 1 server thread is listening for the client and other client thread in writing the message to the server

but my problem is with concurency because when i write in server it appears in client but when i write in client it is not visible to the server unless and until server writes another message
so can you guyz help me this is first time my app contains multithreads
please copy this code and test in your machine for better understanding
server code

client code

The Only way to learn is ...........do!
Visit my blog http://inaved-momin.blogspot.com/
Rohan Dhapodkar

Joined: Jun 27, 2011
Posts: 23
naved momin wrote:

This is issue with go() method of ChatServer, where you are writing to socket first and then creating read thread. Reorder your code and it will work.
Consider Paul's rocket mass heater.
subject: threads concurrency problem
Similar Threads
Threaded Application won't run.
I need help improving this chat server and chat client!
whats wrong in my server code ?
keep getting this exception Address already in use: JVM_Bind
why thread is in running or runnable state why it is not terminated ?