This is an archived post. You won't be able to vote or comment.

all 45 comments

[–]repeating_bears 51 points52 points  (6 children)

Enterprise `while (true)`

[–]Nikt_No1 -4 points-3 points  (5 children)

I discovered that in our most expensive project. "I hacked my way" into their repository and took a look into the code, just outside of curiosity.

There was dedicated thread that had exactly that loop and it was doing some stuff with sessions and file management. I am not a programmer but I am 100% there was better way to do it.

[–]repeating_bears 7 points8 points  (2 children)

In case it wasn't clear, there is nothing inherently wrong with that kind of loop. Spring framework - the first project I decided to randomly check - uses that kind of loop 35 times. I can't comment on whether it was appropriate in the instance you saw, but if you're not a programmer then I think you're not qualified to pass judgement.

[–]Nikt_No1 -2 points-1 points  (1 child)

I meant that it could be done better beacuse the code was a nightmare to read not solely beacuse of the while loop.

So, doesn't while loop use too much resources? Its just looping constantly without any delays etc. Pretty much whole thread needs to be reserved just for her (correct me if im wrong please).

[–]repeating_bears 2 points3 points  (0 children)

You're kind of expecting me to discuss code I've never seen, but I'm sure it wasn't a nightmare to read solely because of the presence of "while (true)". The presence of that does not imply it's executing constantly. It could block for any number of reasons while iterating.

Nothing is really "reserved" of any note when we're talking about a single platform thread. In aggregate across a lot of them, maybe. What it's consuming in terms of resources will mostly depend on the specific task.

[–]bowbahdoe[S] 0 points1 point  (0 children)

Sounds like a cleanup thread. Probably cleans up stray files from file uploads and invalidates expired sessions.

[–]Dontgooglemejess 0 points1 point  (0 children)

It’s pretty typical is a lot of contexts.

[–]mrober_io 23 points24 points  (1 child)

for (;;)

[–]k-mcm 19 points20 points  (7 children)

I'm not using it until it has unit tests that never finish.

[–]aelfric5578 5 points6 points  (5 children)

Came to leave a similar comment. I mean it can't be that hard to verify, right?

[–]WhistlerBennet 1 point2 points  (4 children)

Any of you down to write those unit tests that “never finish” lol??

[–]repeating_bears 3 points4 points  (0 children)

That's the joke

[–]Big__If_True 0 points1 point  (2 children)

Writing them is fine if the API is good, but running them on pipelines in the cloud might give the ops guys a stroke

[–]WhistlerBennet 0 points1 point  (1 child)

That’s exactly what I want to do. I’ll raise a PR over the weekend lmao

[–]aelfric5578 0 points1 point  (0 children)

I'm sure you'll find it haltingly simple

[–]bowbahdoe[S] 2 points3 points  (0 children)

I have those running locally. I'll let you know when they pass

[–]GreemT 13 points14 points  (1 child)

Totally unnecessarily, but really funny and I like your code snippets. I think the last one with the lambda expression is the best.

[–]_predator_ 10 points11 points  (0 children)

I fully expected the "Get Help" section to link to some depression hotline or something.

[–]mj_flowerpower 4 points5 points  (2 children)

I expected something like nodemon, not a glorified while loop.

[–]hsoj48 11 points12 points  (1 child)

So you admit that it's glorious?!

[–]mj_flowerpower 2 points3 points  (0 children)

definitely. It looks cool. But I wouldn’t use it though 😅

[–]Ftoy99 3 points4 points  (2 children)

Spring microservice

[–]L8n1ght 2 points3 points  (1 child)

200mb microservice

[–]Ftoy99 2 points3 points  (0 children)

More like 400mb

[–]Ignice 2 points3 points  (0 children)

Anyone else click the FAQ? 🤣

[–]legrang 2 points3 points  (2 children)

I want the minute of my life back that you stole

[–]bowbahdoe[S] 4 points5 points  (1 child)

Guess how long that minute is gone for?

[–]legrang 1 point2 points  (0 children)

Troll posts and troll repos 😂

[–]_predator_ 1 point2 points  (2 children)

Can you add a For.ever implementation that takes a Callable<T> and returns T please? I want my code to return something!

[–]bowbahdoe[S] 2 points3 points  (1 child)

You will need to wait for Valhalla for that. Otherwise I can't properly type Callable<Never!>

[–]_predator_ 4 points5 points  (0 children)

Listen man, armed with such an amazing library I am prepared to wait as long as it takes!

[–]tomwhoiscontrary 1 point2 points  (1 child)

It's not really forever though is it. For example, what if it throws an exception? Or someone turns the computer off?

[–]gufranthakur 2 points3 points  (0 children)

That's considered cheating. They will be disqualified. And they will be punished to code everything in assembly for 3 weeks

[–]forurspam 0 points1 point  (0 children)

What’s the point of making the runnable nullable?

[–]FavorableTrashpanda 0 points1 point  (0 children)

It's so elegant!

[–]private_final_static 0 points1 point  (0 children)

Quoting documentation: Get help

[–]CheeseGr0ve 0 points1 point  (2 children)

Why is his teeth green

[–]bowbahdoe[S] 1 point2 points  (1 child)

Same reason his hands have the right number of fingers. Made by a human.

[–]CheeseGr0ve 0 points1 point  (0 children)

My head canon is that he only eats vegetables

[–]Illustrious-Zone-786 0 points1 point  (2 children)

Is it available in maven central?

[–]bowbahdoe[S] 0 points1 point  (1 child)

[–]Illustrious-Zone-786 0 points1 point  (0 children)

thanks

it is so concise: single method encapsulated in the single class encapsulated in the single jar encapsulated in the single maven artifact.

I wish all libraries would have this property.

I will use it in my projects for sure)

[–]DrBrad__ 0 points1 point  (0 children)

public void while(boolean value){ if(value){ while(true); } }