+ 2

I was rated 5 out of 10 for this code

Any feedback for this code of odd even printing using two threads? I discussed initially and got feedback that it is only worth of 5 out of 10. Feel free to share your suggestions to improve this code. https://sololearn.com/compiler-playground/cY6n1J39OmTj/?ref=app

12th Feb 2025, 11:35 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
9 Answers
+ 4
it feels over-engineered for such a simple task. But for demonstrating thread synchronization, i think it's ok.. maybe it was rated by people who were taught using namespace std is bad. I have no problem with it. For small demo scripts, I feel it reduces the visual clutter and improves readability. Just as long as one is aware that it's a footgun for bigger codebases. as for it being functional, it's actually a plus for me. OOP is overused and adds a lot of unnecessary boilerplate. Functional and imperative styles go straight for the problem.
13th Feb 2025, 12:50 AM
Bob_Li
Bob_Li - avatar
+ 4
Reported michs23 for spamming. Reasons: New user + invalid analysis of the code + unrelated link + fake website = spam bot. (The real NJ DMV is at https://www.nj.gov/mvc/).
13th Feb 2025, 7:51 AM
Brian
Brian - avatar
+ 3
Brian i was wondering what the race conditions comment was about... it was clearly being addressed to in the code. If this is a bot, it's context recognition is scarily getting better. It can now recognize the topic is about multi threading
13th Feb 2025, 7:59 AM
Bob_Li
Bob_Li - avatar
+ 2
What's the criteria? Improve in which direction?
12th Feb 2025, 4:51 PM
Bob_Li
Bob_Li - avatar
+ 2
Any point is fine. Code readability, code quality, performance enhancement etc. One point I got is the functional paradigm and global variables. It could have been avoided
12th Feb 2025, 7:15 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 2
Hard to give feedback without knowing what the goal/grading criteria were. You mentioned global variables counting against you. Possibly declare and initialize your 3 global variables inside main() and then pass them as arguments to your 2 functions, like you did with maxNum.
13th Feb 2025, 4:29 AM
Shardis Wolfe
+ 2
Bob_Li yes, it is a concerning level of sophistication, like they are testing for weakness and continually revising to become undetectable. I didn't click on the link, as I assume it is for phishing or installing malware.
13th Feb 2025, 8:12 AM
Brian
Brian - avatar
+ 1
Ok. Will change it. Regarding goal of the exercise, it's like trying to implement a better code for printing odd and even numbers with thread synchronization
13th Feb 2025, 4:53 AM
Ketan Lalcheta
Ketan Lalcheta - avatar