What is the difference between concurrency, parallelism and asynchronous methods?

Concurrent and parallel are effectively the same principle as you correctly surmise, both are related to tasks being executed simultaneously although I would say that parallel tasks should be truly multitasking, executed “at the same time” whereas concurrent could mean that the tasks are sharing the execution thread while still appearing to be executing in … Read more

Why must wait() always be in synchronized block

What is the potential damage if it was possible to invoke wait() outside a synchronized block, retaining it’s semantics – suspending the caller thread? Let’s illustrate what issues we would run into if wait() could be called outside of a synchronized block with a concrete example. Suppose we were to implement a blocking queue (I … Read more

Does ruby have real multithreading?

Updated with Jörg’s Sept 2011 comment You seem to be confusing two very different things here: the Ruby Programming Language and the specific threading model of one specific implementation of the Ruby Programming Language. There are currently around 11 different implementations of the Ruby Programming Language, with very different and unique threading models. (Unfortunately, only … Read more

Is there a concurrent List in Java’s JDK?

ConcurrentLinkedQueue If you don’t care about having index-based access and just want the insertion-order-preserving characteristics of a List, you could consider a java.util.concurrent.ConcurrentLinkedQueue. Since it implements Iterable, once you’ve finished adding all the items, you can loop over the contents using the enhanced for syntax: Queue<String> globalQueue = new ConcurrentLinkedQueue<String>(); //Multiple threads can safely call … Read more

SET NOCOUNT ON usage

Ok now I’ve done my research, here is the deal: In TDS protocol, SET NOCOUNT ON only saves 9-bytes per query while the text “SET NOCOUNT ON” itself is a whopping 14 bytes. I used to think that 123 row(s) affected was returned from server in plain text in a separate network packet but that’s … Read more

What is the fastest way to send 100,000 HTTP requests in Python?

Twistedless solution: from urlparse import urlparse from threading import Thread import httplib, sys from Queue import Queue concurrent = 200 def doWork(): while True: url = q.get() status, url = getStatus(url) doSomethingWithResult(status, url) q.task_done() def getStatus(ourl): try: url = urlparse(ourl) conn = httplib.HTTPConnection(url.netloc) conn.request(“HEAD”, url.path) res = conn.getresponse() return res.status, ourl except: return “error”, ourl … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)