Jump to content

Multithreading correctness


Recommended Posts

Howdy folks


Are there any guidelines I should follow to ensure that my mod code is not going to cause multithreading problems?


Most of the time it is obvious because I know whether my code is in a render thread, client tick thread, server thread etc, and the method I'm overriding or implementing gives me the (thread-safe) object I need.


But I think there are some other places where there might be risk of concurrent threads colliding if I call vanilla objects; especially static registration methods of vanilla classes during mod initialisation.


Are ModEventBus events called concurrently if multiple mods are present?  If so, any calls I make to vanilla code from a ModEventBus event is likely to be risky I think.  I hear rumours that DeferredWordQueue::enqueueWork is the method to ensure that registrations using vanilla classes are executed single-threaded, is this the intended method?


What about the server thread, client thread?  Eg are there ever concurrent server threads which may cause my mod to access non-thread-safe objects or methods?  I know there are multiple render threads, which is perfectly safe provided I stick to the objects provided in the calling method or event and don't try to access server or client objects via 'sneaky' methods.


What assumptions is it safe to make?


The worst bugs I've ever had to deal with have all been caused by multithread collisions or race conditions so I'm very keen to understand where the high risk areas are...





Link to comment
Share on other sites

7 minutes ago, diesieben07 said:

although the server uses separate threads for world generation (if I remember correctly)

This is what I believe happens as well. Each chunk may (or may not!) be on its own thread, so you can't reach out too far. I think/hope/assume that the +X/+Z chunks are accessible, due to how vanilla has always handled generation across chunk boundaries before, but I haven't had the time to actually find out. Its possible that there's some precompute (eg. structures) with the structure part bounding boxes and vanilla goes "ok, cool, you want to generate in this volume, that'd be this list of chunks...pooling chunks together...spawning thread...here you go, do what you need."

  • Thanks 1

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.


Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.


DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • 평택스텐드바 ☜BCGAME88·COM◎ 태안스텐드바 군자스텐드바 목동스텐드바 광주스텐드바 mab49 자곡스텐드바 김해스텐드바 팔판스텐드바 합동스텐드바 pkd42 대흥스텐드바 계동스텐드바 정동스텐드바 신정스텐드바 dwb59 삼성스텐드바 당인스텐드바 증산스텐드바 역촌스텐드바 nke60 군포스텐드바 영등포스텐드바 쌍문스텐드바 안산스텐드바 nfw44 삼각스텐드바 충정스텐드바 광주스텐드바 독산스텐드바 ufk03 강남스텐드바 예산스텐드바 충무스텐드바 가락스텐드바 wse18 창동스텐드바 전농스텐드바 성북스텐드바 항동스텐드바 lvj56 오쇠스텐드바 서빙고스텐드바 홍은스텐드바 제주스텐드바 xmt18 예관스텐드바 전농스텐드바 논현스텐드바 갈월스텐드바 aao59 혜화스텐드바 홍은스텐드바 익산스텐드바 사직스텐드바 vds12 진관스텐드바 황학스텐드바 압구정스텐드바 창동스텐드바 ysp11 신대방스텐드바 당산스텐드바 진관스텐드바 공주스텐드바 jnm90 문배스텐드바 공평스텐드바 문배스텐드바 광주스텐드바 dpj42 포천스텐드바 궁동스텐드바 안국스텐드바 구산스텐드바 amy50 석관스텐드바 마천스텐드바 동빙고스텐드바 용문스텐드바 kxt12 거창스텐드바 광주스텐드바 상도스텐드바 완주스텐드바 fcf46 증산스텐드바 이촌스텐드바 영등포스텐드바 시흥스텐드바 fnh43 청량리스텐드바 예장스텐드바 면목스텐드바 구리스텐드바 vhj83 통영스텐드바 파주스텐드바 성구스텐드바 구로스텐드바 agu36 상월곡스텐드바 광희스텐드바 청담스텐드바 전농스텐드바 fya05 남양주스텐드바 홍제스텐드바 인의스텐드바 율현스텐드바 vyo09 평창스텐드바 의정부스텐드바 영등포스텐드바 장충스텐드바 wgv70
    • 오산룸카페 ♣BCGAME88·COM↘ 인현룸카페 수송룸카페 휘경룸카페 체부룸카페 phg60 성북룸카페 이천룸카페 과해룸카페 동대문룸카페 pgf14 중구룸카페 화방룸카페 다동룸카페 구리룸카페 kgd73 청파룸카페 서린룸카페 송현룸카페 녹번룸카페 onf28 삼성룸카페 오산룸카페 산림룸카페 신공덕룸카페 rxf31 안양룸카페 효제룸카페 중랑룸카페 서초룸카페 ndm39 하중룸카페 갈월룸카페 남대문룸카페 연희룸카페 sbw83 적선룸카페 마포룸카페 신대방룸카페 부천룸카페 ckd42 옥천룸카페 인천룸카페 장안룸카페 오장룸카페 bws28 미근룸카페 합동룸카페 신수룸카페 상수룸카페 mkw91 태평룸카페 인의룸카페 아현룸카페 중곡룸카페 boo57 홍천룸카페 양재룸카페 강일룸카페 순화룸카페 duc69 당주룸카페 부천룸카페 궁동룸카페 성산룸카페 qcc17 의왕룸카페 공주룸카페 영천룸카페 계동룸카페 xfd67 여의도룸카페 의주룸카페 와룡룸카페 고척룸카페 gjw96 화동룸카페 강남룸카페 제기룸카페 대치룸카페 asx85 대구룸카페 진주룸카페 태평로룸카페 북창룸카페 nhp97 부암룸카페 견지룸카페 마곡룸카페 원서룸카페 xik38 소격룸카페 하남룸카페 홍지룸카페 견지룸카페 etg70 명일룸카페 필운룸카페 세곡룸카페 부천룸카페 fei18 세곡룸카페 구의룸카페 대흥룸카페 서귀포룸카페 ldy78 자양룸카페 내자룸카페 갈현룸카페 대조룸카페 wrq68 상주룸카페 재동룸카페 문배룸카페 구수룸카페 krx91
    • Direct Entry /Pre degree into,2023/(2024 Rhema University, Obeama-Asa transfer form is out ☎️08O-3664OI34) OR {2348036640134)} …Supplementary Form,Pre-Degree Form (08O3664O134, Jupeb form IJMB Form, masters form,Ph.D  Form,Sandwich Form,Diploma Form,Change of institution form call (08O3664O134 OR {08O3664O134} Change of course Form,POST UTME Form
    • Direct Entry /Pre degree into,2023/(2024 Tansian University, Umunya transfer form is out ☎️08O-3664OI34) OR {2348036640134)} …Supplementary Form,Pre-Degree Form (08O3664O134, Jupeb form IJMB Form, masters form,Ph.D  Form,Sandwich Form,Diploma Form,Change of institution form call (08O3664O134 OR {08O3664O134} Change of course Form,POST UTME Form
    • 화성단란주점 ♠BCGAME88·COM♣ 월계단란주점 돈암단란주점 역삼단란주점 용두단란주점 ydk82 용인단란주점 원효단란주점 북가좌단란주점 삼성단란주점 kmp69 송현단란주점 서린단란주점 금산단란주점 금천단란주점 jfr89 효창단란주점 오산단란주점 외발산단란주점 양주단란주점 kpt13 항동단란주점 구기단란주점 흑석단란주점 송현단란주점 lhy27 익산단란주점 논현단란주점 온수단란주점 김포단란주점 fjn70 역삼단란주점 오류단란주점 의왕단란주점 금천단란주점 syc21 신수단란주점 한남단란주점 안국단란주점 냉천단란주점 bte37 시흥단란주점 마포단란주점 봉원단란주점 권농단란주점 pqc10 과해단란주점 무악단란주점 와룡단란주점 석관단란주점 mkb49 쌍림단란주점 내발산단란주점 혜화단란주점 마곡단란주점 vlw22 마포단란주점 고척단란주점 평창단란주점 당산단란주점 wlx27 광주단란주점 용두단란주점 여주단란주점 이문단란주점 enx86 홍익단란주점 주교단란주점 도렴단란주점 화곡단란주점 arg87 내발산단란주점 칠곡단란주점 옥천단란주점 하계단란주점 juh46 원효단란주점 오곡단란주점 개포단란주점 노고산단란주점 bwx73 숭인단란주점 시흥단란주점 여주단란주점 묵정단란주점 hpu44 배방단란주점 청암단란주점 보광단란주점 마포단란주점 phf31 거제단란주점 광명단란주점 성구단란주점 안산단란주점 pwg54 내발산단란주점 관수단란주점 목포단란주점 평창단란주점 fbx65 흥인단란주점 금천단란주점 함안단란주점 돈암단란주점 cxb24 서린단란주점 남현단란주점 영암단란주점 남가좌단란주점 fpl33 대치단란주점 남학단란주점 양천단란주점 중림단란주점 xth07
  • Topics

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.