Synchronizing threads across different modules
So I have two modules let's call them m1 and m2. So m1 depends on m2 and m1 starts a Thread that does some things using m2, the problem is that I need the thread in m1 and the thread in m2 to exchange information from time to time and for that I would need m2 to also depend on m1 but that creates a circular dependency and as far as I'm aware that's bad (correct me if I am wrong). How should I avoid this? Should I make another module which m1 and m2 depend on and that module handles synchronization and and everything across m1 and m2 or does that just lead to the same problem with extra steps?
31 Replies
⌛
This post has been reserved for your question.
Hey @nikcho-kouhai! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
are you sure this is java related
you cant extend m2 from m1 and m1 from m2, that'd be circular
but m2 using information from m1 and m1 using information from m2 would very well be possible
it is java related
and its not extending I don't think
well I'm not sure if depending and extending mean the same thing they just might but yeah that's exactly what I want to avoid
this circular dependency
how do I get them to use information from each other without making them depend on each other?
you... dont
by making m2 use information from m1, you're creating a dependency
that is what a dependency is
m2 requires m1 to give it information
so there's no way to do it?
that's not what i said
dependencies like that don't matter in java, what you cant do is extend a from b and b from a
well how can I do it ?
there are a bunch of ways to do it, up to you how to solve it
but it also depends on what information at what time
can you perhaps elaborate a little bit? I am not exactly an expert so I don't really know the ways
will doing what I said initially in the post work? In other words have a third module which both the other modules depend on and have that module handle the information exchange between the initial two modules or does that just turn into the same problem?
there's no problem here in the first place, doing it without the 3rd class would be perfectly fine
but adding a 3rd would work, yes
how would I do it without a third module and without making the modules dependant on each other?
you're creating a dependency if you make a get information from b
as mentioned, this isn't an issue tho
wtf ;-;
sooo making a circular dependency isn't an issue?
cause I need a to get information from b and b get information from a
making a depend on b and b depend on a is perfectly fine
if it was only a getting information from b that isn't a problem, yes
you just cant make b extend a and a extend b
as in, inheritance
but that's for classes
I'm talking about modules
I do know that circular inheritance isn't a thing in java
oh jigsaw modules, sorry i thought you just referred to classes as modules
god i fucking hate jigsaw btw
should still be fine tho
the hell is jigsaw xD?
module system
it's the root cause of all the suffering in java
actually contextually I can guess that it just refers to the modules depending on each other
since the jigsaw goes back and forth
well shit
no, jigsaw is just the name of the project the module system was introduced in
fitting name
ohhh
well yes
just the other day I was suffering because of the module system as well
a bunch of shit just blew up all of a sudden
my packages turned to normal folders
that's an ide problem
and packages aren't part of the module system
well yes but it happened as a consequence of me trying to import a project as a module in another project
my module-info file just fucked itself and stopped working as a module-info file and just started working as a .java file
(I could use java keywords but not keywords like module and stuff like that)
I sat down on my chair and it broke (probably not a module issue but I am still blaming the modules for it because I was pretty irriated)
well in any case I would still like to know is it going to be better If I make a third module to managa the informational exchange or should I just throw convention out the window, sell my soul to the devil and make a circular dependency?
whatever floats your boat
both probably work, go nuts
whatever floats my boat better not sink my program
well alright
pray for me I guess
and thanks for the help
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@359755548973072397>.