Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

threads concurrency problem

 
Ranch Hand
Posts: 692
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Yeah, but is it art? What do you think tiny ad?
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic