snipt

Ctrl+h for KB shortcuts
Announcing Snipt for Teams!
Starting at just $49/month.
#137392

Markdown

Double-Checked Locking is Broken

https://snipt.net/embed/f3f819ba97330a13ba731bea50b83620/
https://snipt.net/raw/f3f819ba97330a13ba731bea50b83620/
f3f819ba97330a13ba731bea50b83620
markdown
Markdown
4
2015-07-31T01:30:32
True
True
Nov 27, 2014 at 02:54 AM
/api/public/snipt/137392/
double-checked-locking-is-broken-62ff4ec9
<p><a href="http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html">The "Double-Checked Locking is Broken" Declaration</a></p> <p><a href="http://regrecall.blogspot.ch/2012/05/java-singleton-pattern-thread-safe.html">Java Singleton Pattern Threadsafe</a></p>
java, multithreading, threadsafe
#134696

Java

Hibernate Criteria And Or

1
2
3
4
5
6
Criteria criteria = getSession().createCriteria(clazz); 
Criterion rest1= Restrictions.and(Restrictions.eq("A", "X"), 
           Restrictions.in("B", Arrays.asList("X","Y")));
Criterion rest2= Restrictions.and(Restrictions.eq("A", "Y"), 
           Restrictions.eq("B", "Z"));
criteria.add(Restrictions.or(rest1, rest2));
https://snipt.net/embed/8aceb2963b54dee89d38c00f771b1477/
https://snipt.net/raw/8aceb2963b54dee89d38c00f771b1477/
8aceb2963b54dee89d38c00f771b1477
java
Java
6
2015-08-02T01:56:39
True
False
May 02, 2014 at 04:16 PM
/api/public/snipt/134696/
hibernate-criteria-and-or-d04f6474
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="n">Criteria</span> <span class="n">criteria</span> <span class="o">=</span> <span class="n">getSession</span><span class="o">().</span><span class="na">createCriteria</span><span class="o">(</span><span class="n">clazz</span><span class="o">);</span> </span><span id="L-2"><a name="L-2"></a><span class="n">Criterion</span> <span class="n">rest1</span><span class="o">=</span> <span class="n">Restrictions</span><span class="o">.</span><span class="na">and</span><span class="o">(</span><span class="n">Restrictions</span><span class="o">.</span><span class="na">eq</span><span class="o">(</span><span class="s">&quot;A&quot;</span><span class="o">,</span> <span class="s">&quot;X&quot;</span><span class="o">),</span> </span><span id="L-3"><a name="L-3"></a> <span class="n">Restrictions</span><span class="o">.</span><span class="na">in</span><span class="o">(</span><span class="s">&quot;B&quot;</span><span class="o">,</span> <span class="n">Arrays</span><span class="o">.</span><span class="na">asList</span><span class="o">(</span><span class="s">&quot;X&quot;</span><span class="o">,</span><span class="s">&quot;Y&quot;</span><span class="o">)));</span> </span><span id="L-4"><a name="L-4"></a><span class="n">Criterion</span> <span class="n">rest2</span><span class="o">=</span> <span class="n">Restrictions</span><span class="o">.</span><span class="na">and</span><span class="o">(</span><span class="n">Restrictions</span><span class="o">.</span><span class="na">eq</span><span class="o">(</span><span class="s">&quot;A&quot;</span><span class="o">,</span> <span class="s">&quot;Y&quot;</span><span class="o">),</span> </span><span id="L-5"><a name="L-5"></a> <span class="n">Restrictions</span><span class="o">.</span><span class="na">eq</span><span class="o">(</span><span class="s">&quot;B&quot;</span><span class="o">,</span> <span class="s">&quot;Z&quot;</span><span class="o">));</span> </span><span id="L-6"><a name="L-6"></a><span class="n">criteria</span><span class="o">.</span><span class="na">add</span><span class="o">(</span><span class="n">Restrictions</span><span class="o">.</span><span class="na">or</span><span class="o">(</span><span class="n">rest1</span><span class="o">,</span> <span class="n">rest2</span><span class="o">));</span> </span></pre></div> </td></tr></table>
criteria, hibernate, java
#122719

Text only

Linux renice all java processes

ps fax | grep java | awk '{print $1;}' | xargs renice -n 19
https://snipt.net/embed/d8118159753138d887723bfd65b14f1e/
https://snipt.net/raw/d8118159753138d887723bfd65b14f1e/
d8118159753138d887723bfd65b14f1e
text
Text only
1
2015-08-02T10:12:00
True
False
Mar 18, 2014 at 06:33 AM
/api/public/snipt/122719/
linux-renice-all-java-processes
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>ps fax | grep java | awk &#39;{print $1;}&#39; | xargs renice -n 19 </span></pre></div> </td></tr></table>
java, linux, renice
Copyrighted, illegal, or inappropriate content? Email nick@snipt.net.