Make client-side background threads daemon.

Reduced the amount of logging from invalid UDP messages
received.


git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7314 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
PSp..om 14 years ago
parent 0d4e07f924
commit 1b837fe7ea
  1. 2
      engine/src/networking/com/jme3/network/base/ConnectorAdapter.java
  2. 4
      engine/src/networking/com/jme3/network/base/KernelAdapter.java
  3. 13
      engine/src/networking/com/jme3/network/kernel/NamedThreadFactory.java

@ -82,7 +82,7 @@ public class ConnectorAdapter extends Thread
this.reliable = reliable; this.reliable = reliable;
setDaemon(true); setDaemon(true);
writer = Executors.newFixedThreadPool(1, writer = Executors.newFixedThreadPool(1,
new NamedThreadFactory(String.valueOf(connector) + "-writer")); new NamedThreadFactory(String.valueOf(connector) + "-writer", true));
} }
public void close() public void close()

@ -143,7 +143,11 @@ public class KernelAdapter extends Thread
try { try {
HostedConnection source = getConnection(p); HostedConnection source = getConnection(p);
if( source == null ) { if( source == null ) {
if( reliable ) {
// If it's a reliable connection then it's slightly more
// concerning but this can happen all the time for a UDP endpoint.
log.log( Level.WARNING, "Recieved message from unconnected endpoint:" + p + " message:" + m ); log.log( Level.WARNING, "Recieved message from unconnected endpoint:" + p + " message:" + m );
}
return; return;
} }
messageDispatcher.messageReceived( source, m ); messageDispatcher.messageReceived( source, m );

@ -46,6 +46,7 @@ import java.util.concurrent.ThreadFactory;
public class NamedThreadFactory implements ThreadFactory public class NamedThreadFactory implements ThreadFactory
{ {
private String name; private String name;
private boolean daemon;
private ThreadFactory delegate; private ThreadFactory delegate;
public NamedThreadFactory( String name ) public NamedThreadFactory( String name )
@ -53,9 +54,20 @@ public class NamedThreadFactory implements ThreadFactory
this( name, Executors.defaultThreadFactory() ); this( name, Executors.defaultThreadFactory() );
} }
public NamedThreadFactory( String name, boolean daemon )
{
this( name, daemon, Executors.defaultThreadFactory() );
}
public NamedThreadFactory( String name, ThreadFactory delegate ) public NamedThreadFactory( String name, ThreadFactory delegate )
{
this( name, false, delegate );
}
public NamedThreadFactory( String name, boolean daemon, ThreadFactory delegate )
{ {
this.name = name; this.name = name;
this.daemon = daemon;
this.delegate = delegate; this.delegate = delegate;
} }
@ -64,6 +76,7 @@ public class NamedThreadFactory implements ThreadFactory
Thread result = delegate.newThread(r); Thread result = delegate.newThread(r);
String s = result.getName(); String s = result.getName();
result.setName( name + "[" + s + "]" ); result.setName( name + "[" + s + "]" );
result.setDaemon(daemon);
return result; return result;
} }
} }

Loading…
Cancel
Save