Mercurial > hg > Database > Alice
changeset 20:0bb03861b5cd
set name to Thread
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 15 Jan 2012 18:44:25 +0900 |
parents | e7867328a2fb |
children | 145667a554ad |
files | src/alice/codesegment/CodeSegmentManager.java src/alice/datasegment/DataSegmentKey.java src/alice/datasegment/LocalDataSegmentManager.java src/alice/datasegment/RemoteDataSegmentManager.java src/alice/test/codesegment/TestRemoteAlice.java |
diffstat | 5 files changed, 15 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/codesegment/CodeSegmentManager.java Sun Jan 15 17:57:05 2012 +0900 +++ b/src/alice/codesegment/CodeSegmentManager.java Sun Jan 15 18:44:25 2012 +0900 @@ -22,7 +22,7 @@ } }; - new Thread(prepareThread).start(); + new Thread(prepareThread, "CodeSegmentManager").start(); } public void create(CodeSegment cs) {
--- a/src/alice/datasegment/DataSegmentKey.java Sun Jan 15 17:57:05 2012 +0900 +++ b/src/alice/datasegment/DataSegmentKey.java Sun Jan 15 18:44:25 2012 +0900 @@ -9,14 +9,15 @@ public class DataSegmentKey { + private String key; private LinkedBlockingQueue<Command> cmdQueue = new LinkedBlockingQueue<Command>(); private ArrayList<DataSegmentValue> dataList = new ArrayList<DataSegmentValue>(); private ArrayList<Command> waitList = new ArrayList<Command>(); private AtomicInteger tailIndex = new AtomicInteger(1); - private Runnable keyThread; + private Thread keyThread; - public DataSegmentKey() { - + public DataSegmentKey(String key) { + this.key = key; } public void addCommand(Command cmd) { @@ -24,7 +25,7 @@ } public void runKeyThread() { - keyThread = new Runnable() { + this.keyThread = new Thread() { @Override public void run() { while (true) { @@ -51,7 +52,6 @@ break; } } - } break; case PEEK: @@ -96,7 +96,8 @@ } } }; - new Thread(keyThread).start(); - }; + keyThread.setName("DataSegmentKey-" + key); + keyThread.start(); + } }
--- a/src/alice/datasegment/LocalDataSegmentManager.java Sun Jan 15 17:57:05 2012 +0900 +++ b/src/alice/datasegment/LocalDataSegmentManager.java Sun Jan 15 18:44:25 2012 +0900 @@ -8,14 +8,14 @@ public class LocalDataSegmentManager extends DataSegmentManager { public LocalDataSegmentManager() { - new Thread(replyThread).start(); + new Thread(replyThread, "LocalDataSegmentManager").start(); } public DataSegmentKey getDataSegmentKey(String key) { if (key == null) { return null; } - DataSegmentKey newDataSegmentKey = new DataSegmentKey(); + DataSegmentKey newDataSegmentKey = new DataSegmentKey(key); DataSegmentKey dataSegmentKey = dataSegments.putIfAbsent(key, newDataSegmentKey); if (dataSegmentKey == null) { newDataSegmentKey.runKeyThread();
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Sun Jan 15 17:57:05 2012 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Sun Jan 15 18:44:25 2012 +0900 @@ -15,7 +15,9 @@ this.connection = connection; new IncomingTcpConnection(connection, this).start(); new OutboundTcpConnection(connection).start(); - new Thread(replyThread).start(); + new Thread(replyThread, "RemoteDataSegmentManager-" + + connection.socket.getInetAddress().getHostName() + + ":" + connection.socket.getPort()).start(); } @Override
--- a/src/alice/test/codesegment/TestRemoteAlice.java Sun Jan 15 17:57:05 2012 +0900 +++ b/src/alice/test/codesegment/TestRemoteAlice.java Sun Jan 15 18:44:25 2012 +0900 @@ -15,16 +15,7 @@ public static void main(String[] args) { Config conf = new Config(args); - final AliceDaemon daemon = new AliceDaemon(conf); - new Thread() { - - @Override - public void run() { - // TODO Auto-generated method stub - daemon.listen(); - } - - }.start(); + new AliceDaemon(conf).listen(); boolean connect = true; do {