Commit bb55e9d7 authored by Jonathan Poalses's avatar Jonathan Poalses

Updated gradle and java version, changed to using executor service, added git ignore

parent bdc81554
### Leiningen ###
/.lein-*
/.nrepl-port
/.prepl-port
### IntelliJ IDEA ###
*.iml
*.ipr
modules.xml
.idea/
cmake-build-*/
*.iws
out/
.idea_modules/
atlassian-ide-plugin.xml
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
### Java ###
*.class
*.log
*.ctxt
.mtj.tmp/
*.jar
!gradle-wrapper.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
### Mercurial ###
.hgignore
.hg/
### VSCode/Calva ###
.calva/
.clj-kondo/
.lsp/
### Misc ###
/target
/classes
/checkouts
profiles.clj
pom.xml
pom.xml.asc
# Ignore Gradle project-specific cache directory
.gradle
# Ignore Gradle build output directory
build
/local/*.hprof
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
...@@ -4,6 +4,7 @@ package jonathan.poalses; ...@@ -4,6 +4,7 @@ package jonathan.poalses;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.concurrent.Executors;
// Server class // Server class
public class Server { public class Server {
...@@ -16,6 +17,7 @@ public class Server { ...@@ -16,6 +17,7 @@ public class Server {
} }
private static void handle(ServerSocket serverSocket) throws IOException { private static void handle(ServerSocket serverSocket) throws IOException {
try (var executor = Executors.newCachedThreadPool()) {
while (true) { while (true) {
Socket socket = null; Socket socket = null;
...@@ -32,11 +34,8 @@ public class Server { ...@@ -32,11 +34,8 @@ public class Server {
System.out.println("Assigning new thread for this client"); System.out.println("Assigning new thread for this client");
outputStream.writeUTF("{Server} Connection Successful\n"); outputStream.writeUTF("{Server} Connection Successful\n");
// create a new thread object // Create a server thread
Thread thread = new Thread(new ServerThread(socket, inputStream, outputStream)); executor.submit(new ServerThread(socket, inputStream, outputStream));
// Invoking the start() method
thread.start();
} catch (Exception e) { } catch (Exception e) {
if (socket != null) { if (socket != null) {
...@@ -46,5 +45,6 @@ public class Server { ...@@ -46,5 +45,6 @@ public class Server {
} }
} }
} }
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment