Javamex2024-03-29T09:59:38ZRainald Kochhttp://javamex.ning.com/profile/RainaldKochhttp://static.ning.com/socialnetworkmain/widgets/profiles/gfx/defaults/profile-006699.png?xn_version=431723162&width=48&height=48&crop=1%3A1&xj_user_default=1http://javamex.ning.com/forum/topic/listForContributor?user=38nnvm6s5hax5&feed=yes&xn_auth=nolock.lock v/s synchronizedtag:javamex.ning.com,2012-04-12:2843556:Topic:121222012-04-12T10:59:42.687ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>The thread calling synchronzed(obj) acquires and owns that objects monitor till it releases it. Does lock.lock also behaves in a similar fashion. I tried calling lock.wait() after lock.lock() using an instance of ReentrantLock and the code gave me IllegalMonitorStateException.</p>
<p>The thread calling synchronzed(obj) acquires and owns that objects monitor till it releases it. Does lock.lock also behaves in a similar fashion. I tried calling lock.wait() after lock.lock() using an instance of ReentrantLock and the code gave me IllegalMonitorStateException.</p> How to setup JProfiler ?tag:javamex.ning.com,2012-04-05:2843556:Topic:119222012-04-05T10:05:32.674ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>How to setup JProfiler ?</p>
<p>How to setup JProfiler ?</p> Stop variables and volatilitytag:javamex.ning.com,2012-03-21:2843556:Topic:115292012-03-21T09:39:47.639ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>Hi folks, In the article about stopping a thread, it was said that a stop variable needs to be volitile.</p>
<p>I can see that if the variable is public and other threads can alter it directly. But is this still true if the stop variable is private and encapsulation is used to set it?</p>
<p>Hi folks, In the article about stopping a thread, it was said that a stop variable needs to be volitile.</p>
<p>I can see that if the variable is public and other threads can alter it directly. But is this still true if the stop variable is private and encapsulation is used to set it?</p> Handle InterruptedExceptiontag:javamex.ning.com,2012-03-20:2843556:Topic:114302012-03-20T15:51:57.687ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>I see recommendation of handling InterruptedException to keep the interrupt flag, like this:</p>
<p>catch (InterruptedException iex) {</p>
<p> Thread.currentThread().interrupt();</p>
<p>}</p>
<p> </p>
<p>But, if you do this, the thread ends immediately. If you have a finally clause after catch clause, it won't run. Even worse, all statements after the try/catch/finally won't run. I said, this ends the thread immediately, the whole stach cleared, no Exception rethrown. I feel this is an…</p>
<p>I see recommendation of handling InterruptedException to keep the interrupt flag, like this:</p>
<p>catch (InterruptedException iex) {</p>
<p> Thread.currentThread().interrupt();</p>
<p>}</p>
<p> </p>
<p>But, if you do this, the thread ends immediately. If you have a finally clause after catch clause, it won't run. Even worse, all statements after the try/catch/finally won't run. I said, this ends the thread immediately, the whole stach cleared, no Exception rethrown. I feel this is an odd sematics - a big bug.</p>
<p>I am attaching two files. Compile them and run. (java 1.5). Please comment.</p>
<p> </p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2310756837?profile=original" target="_self">InterruptOther.java</a></p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2310756749?profile=original" target="_self">InterruptSelf.java</a></p>
<p> </p>
<p> </p>
<p> </p> Where can I download the source code, esp for Blocking Queue Thread exampletag:javamex.ning.com,2012-01-11:2843556:Topic:98362012-01-11T19:16:10.504ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>keep up the good work. I am planning to understand Blocking queue example. I would appreaciate</p>
<p>where I can down load the LoggerThread class source code so that I can test.</p>
<p>TYI</p>
<p>Ram</p>
<p></p>
<p>keep up the good work. I am planning to understand Blocking queue example. I would appreaciate</p>
<p>where I can down load the LoggerThread class source code so that I can test.</p>
<p>TYI</p>
<p>Ram</p>
<p></p> notify vs notifyalltag:javamex.ning.com,2011-08-24:2843556:Topic:66232011-08-24T13:50:46.599ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<div class="mcePaste" id="_mcePaste" style="xg-p: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"></div>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2310756781?profile=original" target="_self">Queue.java</a></p>
<p> </p>
<p>Attached is a file containing a simple producer consumer scenario that I wrote.</p>
<p>Changing queue.notifyAll() to queue.notify() in the push method creates a deadlock.</p>
<p>Not sure why? Is there any significant…</p>
<div class="mcePaste" id="_mcePaste" style="xg-p: absolute; width: 1px; height: 1px; overflow: hidden; top: 0px; left: -10000px;"></div>
<p><a target="_self" href="http://storage.ning.com/topology/rest/1.0/file/get/2310756781?profile=original">Queue.java</a></p>
<p> </p>
<p>Attached is a file containing a simple producer consumer scenario that I wrote.</p>
<p>Changing queue.notifyAll() to queue.notify() in the push method creates a deadlock.</p>
<p>Not sure why? Is there any significant difference between notify and notifyAll which I am missing?</p>
<p> </p>
<p> </p>
<p>Thanks,</p>
<p>Pallav</p> error in Java hashtable implementation?tag:javamex.ning.com,2011-08-02:2843556:Topic:56252011-08-02T22:36:31.232ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>On the page with the code for the get() and put() methods for the hashtable: I assume "hc" in the second line of each function should be "hash", correct?</p>
<p> </p>
<p>- Mike</p>
<p>On the page with the code for the get() and put() methods for the hashtable: I assume "hc" in the second line of each function should be "hash", correct?</p>
<p> </p>
<p>- Mike</p> Online survey for IT/Software professionals in UStag:javamex.ning.com,2011-06-21:2843556:Topic:49222011-06-21T18:18:51.378ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>HI all,</p>
<p><br></br>I am presently conducting an online survey for IT/Software professionals in USA as a part of my MBA dissertation, i appreciate the participation of US based IT/Software professionals in the group and also please pass it on to your known people working in US IT/Software sector.</p>
<p><br></br>Survey link: <a href="http://www.surveymonkey.com/s/VPJJZRL" target="_blank">http://www.surveymonkey.com/s/VPJJZRL</a></p>
<p><br></br>Thanks in advance!</p>
<p>Best…</p>
<p>HI all,</p>
<p><br/>I am presently conducting an online survey for IT/Software professionals in USA as a part of my MBA dissertation, i appreciate the participation of US based IT/Software professionals in the group and also please pass it on to your known people working in US IT/Software sector.</p>
<p><br/>Survey link: <a target="_blank" href="http://www.surveymonkey.com/s/VPJJZRL">http://www.surveymonkey.com/s/VPJJZRL</a></p>
<p><br/>Thanks in advance!</p>
<p>Best Regards</p>
<p><br/>Vivek</p> Questions on AES CTR mode initalization vectortag:javamex.ning.com,2011-02-03:2843556:Topic:21062011-02-03T16:39:50.000ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
<p>Great tutorial on Java encryption. I keep coming back to it for reference. Perhaps you could clarify something for me though regarding AES CTR block mode initalization vector. I haven't been able to find anything on the web about Sun's format for the IV. You mention that the lowest order bytes are the ones that toggle:</p>
<p> …</p>
<p></p>
<p>Great tutorial on Java encryption. I keep coming back to it for reference. Perhaps you could clarify something for me though regarding AES CTR block mode initalization vector. I haven't been able to find anything on the web about Sun's format for the IV. You mention that the lowest order bytes are the ones that toggle:</p>
<p> </p>
<p><em><a href="http://www.javamex.com/tutorials/cryptography/initialisation_vector.shtml">http://www.javamex.com/tutorials/cryptography/initialisation_vector.shtml</a></em></p>
<p><em>This IV would be compatible with Sun's implementation of CTR mode, where the counter is big endian (i.e. the highest byte of the IV actually represents the lowest-order part of the counter, and is the "part that incremenst first"). The advantage of this solution is that in many cases, you may be keeping a message counter anyway.</em></p>
<p><em> </em></p>
<p>Isn't this little endian? I think the example also needs to specify the endian for the ByteBuffer, or else it uses the native (which is typically little, on most PCs). </p>
<p><span style="font-family: courier new,courier;">ByteBuffer bb = ByteBuffer.allocate(16);</span></p>
<p><span style="font-family: courier new,courier; color: #ff0000;">bb.order(ByteOrder.LITTLE_ENDIAN);</span><br/><span style="font-family: courier new,courier;">bb.putLong(0, messageNo);</span></p>
<p> </p>
<p>Does Sun use a 8 byte counter (long)?</p>
<p> </p>
<p>I've seen elsewhere on the web where a nonce is added to the upper 8 bytes instead of filling them with zeroes but no clear explanation of why. Thoughts?</p>
<p> </p>
<p>-Rex</p> Symmetric vs Asymmetric encryption - which is stronger in Java?tag:javamex.ning.com,2010-09-29:2843556:Topic:20832010-09-29T15:30:53.000ZRainald Kochhttp://javamex.ning.com/profile/RainaldKoch
Hi,<br></br>
<br></br>
Just finished reading the Cryptography tutorial on the website and I<br />
have to say that it is hands down the most comprehensive overview<br />
available on the net. Congrats!!<br></br><br></br>Symmetric keys in Java seem to have a limitation of 2^160 due to implementation of SecureRandom. Whereas for asymmetric key based encryption (e.g. RSA), the upper bound would be the CPU/8192 bits.<br></br><br></br>If key exchange and CPU cycles were not a concern, what method would provide stronger encryption in…
Hi,<br/>
<br/>
Just finished reading the Cryptography tutorial on the website and I<br />
have to say that it is hands down the most comprehensive overview<br />
available on the net. Congrats!!<br/><br/>Symmetric keys in Java seem to have a limitation of 2^160 due to implementation of SecureRandom. Whereas for asymmetric key based encryption (e.g. RSA), the upper bound would be the CPU/8192 bits.<br/><br/>If key exchange and CPU cycles were not a concern, what method would provide stronger encryption in Java (JDK 1.6) without any third party additions - AES 256 (quasi 160) or RSA 4096?<br/><br/>Any thoughts?<br/><br/>Thanks.<br/><br/>Janak<br/><br/>