# HG changeset patch # User Frank Benoit # Date 1221205476 -7200 # Node ID 9e7e1a8bc8131ec978126211ffd58e520a749bd9 # Parent c6d7b1ea700bd379fb86cefc0d1c795f55507444 get a JThread for a thread that was just a Thread. diff -r c6d7b1ea700b -r 9e7e1a8bc813 dwtx/dwtxhelper/JThread.d --- a/dwtx/dwtxhelper/JThread.d Thu Sep 11 00:32:24 2008 +0200 +++ b/dwtx/dwtxhelper/JThread.d Fri Sep 12 09:44:36 2008 +0200 @@ -52,7 +52,18 @@ } public static JThread currentThread(){ - return getTls().val(); + auto res = getTls().val(); + if( res is null ){ + synchronized(JThread.classinfo){ + res = getTls().val(); + if( res is null ){ + res = new JThread(); + res.thread = Thread.getThis(); + getTls().val( res ); + } + } + } + return res; } public int getPriority() { return (thread.priority-Thread.PRIORITY_MIN) * (MAX_PRIORITY-MIN_PRIORITY) / (Thread.PRIORITY_MAX-Thread.PRIORITY_MIN) + MIN_PRIORITY;