On using Lock variables because of multithreadedness

20 views
Skip to first unread message

goodnews...@gmail.com

unread,
Apr 23, 2018, 6:06:41 PM4/23/18
to Netty discussions
Hello,

I've been coding a Netty server for over a year.
My games communicate and play well with it.

I ran into one problem:

I have the standard workergroup, bossgroup thing that spawns threads for every connection.

I also have another thread that is a loop that gives players rewards based on time, and logs timed out players off.

Without locks, the main loop throws exceptions with variables when two threads try and access at the same time.

Is there any general philosophy I should use than having global locks for the specific variables being accessed, and making the locks as simple as possible?

,Jim

goodnews...@gmail.com

unread,
Apr 23, 2018, 6:23:47 PM4/23/18
to Netty discussions
Solved: I get socket strings write it behind a lock, and do all the processing in the main loop by reading it behind a lock. Ez pz.
Reply all
Reply to author
Forward
0 new messages