blockgoblin31
blockgoblin31
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
Thank you, this worked!
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
That lambda is where we get the input (it’s the message parameter), and it’s run on the main thread later
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
Yes
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
So let me phrase this differently(I don’t know exactly how the main code works, I’m writing an addon with an api), all messages go through the main thread and this is triggered by a message. So for other messages to be processed the main thread has to be freed, and this needs another message before it can finish its task.
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
yeah I know, that was just quicker for my example
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
(well other than while (type == null) {})
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
so I need the code to wait until the value is set, and I'm not sure how to do that
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
the main thread can't just wait forever because then we wouldnt handle messages from other users
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
the problem is I need to know that type is not null before the code continues, and that requires the specific user to send a valid message.
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
and it gets the message from side threads that are actually doing the listening for user input
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
its run on the main thread when it gets a message
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
as a simplified example:
SelectionType type;
//runner handles the user input
runner.captureMessagesFrom(user, (message) -> {
switch (message.toLowerCase()) {
case "draft" -> type = SelectionType.DRAFT;
case "set" -> type = SelectionType.SET;
case "random" -> type = SelectionType.RANDOM;
default -> return false;
}
return true;
}
//use type for something
SelectionType type;
//runner handles the user input
runner.captureMessagesFrom(user, (message) -> {
switch (message.toLowerCase()) {
case "draft" -> type = SelectionType.DRAFT;
case "set" -> type = SelectionType.SET;
case "random" -> type = SelectionType.RANDOM;
default -> return false;
}
return true;
}
//use type for something
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
the main thread is getting a lambda that extends a specific interface for it to run messages through
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
I'm not
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
no, user input is handled on the main thread. I'm passing the thing that handles user input a lambda to run the message through and I want to continue the side thread when that lambda has gotten valid input
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
because I can't stop the main thread until the user gives input(This is eventally going to be server side code on something with multiple users)
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
specifically im looking for one of "draft", "set", or "random"
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
oh it needs to be one of three strings(selecting an option)
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 10/31/2024 in #java-help
How would I have a thread wait on a lambda?
Right now just a string from terminal, but thats for testing.
55 replies
JCHJava Community | Help. Code. Learn.
Created by blockgoblin31 on 7/27/2024 in #java-help
Why/how is displayMap null
(Not my code, trying to help a friend troubleshoot)
5 replies