java - Two different classes A and B on their own thread calling a method of the same class instance C -


so i've got simple server class creates instance of listener class every connection made "server". listeners run on own thread.

i there might concurrency control problem when invoking methods on server class alter files/variables. happens if 2 listeners try invoke method e.g. returns information server status? can same server instance handle 2 calls @ same time? or 1 of listeners have wait till server done executing method of first caller?

thanks guys might able provide!

if method not synchronized, server can handle 2 calls concurrently.

but if ask status, means status changes on time. , if changes on time, accesses, read , write, status should done in synchronized way. otherwise, listener threads see obsolete value of status.

so method should synchronized, or status should atomicxxx value, or should volatile. best, , correct solution hard give without seeing code , knowing how status read , modified.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -