Note that there are some explanatory texts on larger screens.

plurals
  1. POmultiple threads using same value fetched by database DAO class method
    primarykey
    data
    text
    <p><strong><code>Status: solved</code></strong></p> <p>I had to make a pastebin as I had to point out line numbers.</p> <p><strong>note:</strong> not using executorsService or thread pools. just to understand that what is wrong in starting and using threads this way. <strong>If I use 1 thread. the app works Perfect!</strong></p> <p>related links:</p> <p><a href="http://www.postgresql.org/docs/9.1/static/transaction-iso.html" rel="nofollow">http://www.postgresql.org/docs/9.1/static/transaction-iso.html</a> <a href="http://www.postgresql.org/docs/current/static/explicit-locking.html" rel="nofollow">http://www.postgresql.org/docs/current/static/explicit-locking.html</a></p> <p><code>main app,</code> <a href="http://pastebin.com/i9rVyari" rel="nofollow">http://pastebin.com/i9rVyari</a> <code>logs</code>, <a href="http://pastebin.com/2c4pU1K8" rel="nofollow">http://pastebin.com/2c4pU1K8</a> , <a href="http://pastebin.com/2S3301gD" rel="nofollow">http://pastebin.com/2S3301gD</a></p> <p>I am starting many threads (10) in a for loop with instantiating a <code>runnable</code> class but it seems I am getting same result from <code>db</code> (I am geting some string from db, then changing it) but with <strong><code>each thread, I get same string</code></strong> (despite each thread changed it.) . using <code>jdbc</code> for <code>postgresql</code> what might be the usual issues ?</p> <pre><code>line 252 and line 223 </code></pre> <p>the link is marked as <code>processed. (true)</code> in db. other threads of <code>crawler class</code> also do it. so when <code>line 252</code> should get a link. it should be <code>processed = false</code>. but I see all <code>threads take same link.</code></p> <p>when one of the threads crawled the link . it makes it processed = true. the others then should not crawl it. (get it) is its marked processed = true. </p> <hr> <p><code>getNonProcessedLinkFromDB()</code> returns a non processed link</p> <pre><code>public String getNonProcessedLink(){ line 645 public boolean markLinkAsProcesed(String link){ line 705 </code></pre> <p><code>getNonProcessedLinkFromDB</code> will see for processed = false links and give one out of them . <code>limit 1</code> <strong>each thread has a starting interval gap of 20 secs.</strong><br> within one thread. 1 or 2 seconds (estimate processing time for crawling)</p> <pre><code>line 98 keepS threads from grabbing the same url </code></pre> <p><strong>if you see the result. one thread made it true. still others access it. waaaay after some time.</strong></p> <p>all thread are seperate. even one <code>races</code>. the <strong>db makes the link true at the moment the first thread processes it</strong></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload