How do I run two codes at a time (in java)
The title basically says it all, when you press the run button two files run at the same time... Any help?
Thanks,
Amaddentcsec
I don't do much java, but you can take a look at multithreading in java: https://www.geeksforgeeks.org/multithreading-in-java/
Are you talking about having two separate instances running one file each, or one instance running both files at the same time?
@SixBeeps
running both files at the same time
@amaddentcsec Yeah I understand that, but how many instances do you want running? Do you want to multithread (same instance) or just have two separate instances?
@SixBeeps
multithread i suppose
@amaddentcsec Just to make sure that's what you want, what do you plan on achieving by running multiple files? Is is for something like a server and a client?
@SixBeeps
I'm making an ascii game in java....
@amaddentcsec Then why do you need to create two separate files? Are you creating numerous classes?
@SixBeeps
One file for getting input, one file to run the game
@amaddentcsec So you want to check for input while you do stuff with the game? You should do that in one file, listening to KeyEvents. I don't think Repl.it supports it, but it's worth looking in to: https://stackoverflow.com/questions/18037576/how-do-i-check-if-the-user-is-pressing-a-key
@amaddentcsec Hi,
Check this website and Please don't forget to say your feedback in the Comments
Click here
Thanks!
Hope this helps
@PattanAhmed
Dang this looks like it will work!
Thanks!
@amaddentcsec Welcome!
Happy to help!