concurrency

Select million+ records while huge insert is running

I am trying to extract application log file from a single table. The select query statement is pretty straightforward. select top 200000 * from dbo.transactionlog where rowid>7 and rowid <700000 and Project='AmWINS' The query time for above select is above 5 mins. Is it considered long? While the select is running, the bulk insert...

Make it pretty: processing an array concurrently

I want to convert this linear loop into a concurrent one: for(Item item : ItemList) { processItem(item); } Is this really the shortest way to do this? class Worker implements Runnable { Item item; Worker(Item item) { this.item = item; } public void Run() { processItem(item); } } ExecutorServic...

Starting a Java class in different threads

Hi all! I'm wondering how i can call a class from different threads, and have all the calls run in it's own thread? Lets say I have three threads, and each of them need to call anotherClass.getBS(), but the calls might come at the same time, and there's no reason to perform them one at the time. Deadlocks are not a problem. Thanks! ...

Scheduling Swingworker threads

Hi, I have a 2 processes to perform in my swing application, one to fill a list, and one to do operations on each element on the list. I've just moved the 2 processes into Swingworker threads to stop the GUI locking up while the tasks are performed, and because I will need to do this set of operations to several lists, so concurrency wo...

how to assign different concurrency strategy to the same (persistence) entity?

I'm using JPA and I am using second-level cache for all the reference entities. Everything's working well, I can get the entities from second-level cache is they were already been selected before. Now, I have two applications, they both use the same database (so they both use the same table, values, etc). 1.The read-only application ju...

Where can I find some good examples to learn the basics of threading?

I am at the end of my first year doing computer science and want to mess around with something basic. I want to use threads so I can learn. What are some good examples to learn from? ...

This class uses AtomicBooleans. Is it thread safe ?

I don't like to lock up my code with synchronized(this), so I'm experimenting with using AtomicBooleans. In the code snippet, XMPPConnectionIF.connect() makes a socket connection to a remote server. Note that the variable *connecting is only ever used in the connect() method; whereas *connected is used in every other methods that needs t...

How to track task execution statistics using an ExecutorService?

I'm firing off tasks using an ExecutorService, dispatching tasks that need to be grouped by task-specific criteria: Task[type=a] Task[type=b] Task[type=a] ... Periodically I want to output the average length of time that each task took (grouped by type) along with statistical information such as mean/median and standard deviation. Th...

Running a separate process or thread in Qt

I'm writing my first proper useful piece of software. Part of it will involve the user viewing an image, and choosing to accept or reject it. Doing this will cause the image to be saved to an accepted or rejected folder, and possibly rotated and/or resized. At the moment, my rotate/resize/save operation is pausing execution of my progra...

Use WCF to safely let lots of concurrent users access MS-Access or Sqlite or other file based DB safely?

I want to write a data access layer for a file based database behind a data driven website. There would be lots of concurrent update and reads going on, I'd like at the very least that access be serialized, so that page request would get in a nice orderly line. What WCF configurations would get me what I want? Does PerSession concurre...

Is there a .Net equivalent to java.util.concurrent.Executor ?

Hello, Have a long running set of discrete tasks: parsing 10s of thousands of lines from a text file, hydrating into objects, manipulating, and persisting. If I were implementing this in Java, I suppose I might add a new task to an Executor for each line in the file or task per X lines (i.e. chunks). For .Net, which is what I am usi...

High-traffic percentage-based set picks?

The setup: High traffic website and a list of image URLs that we want to display. We have one image spot, and each item in the set of image URLs has a target display percentage for the day. Example: Image1 - 10% Image2 - 30% Image3 - 60% Because the traffic amount can vary from day to day, I'm doing the percentages within blocks of 1...

Concurrent Haskell Actions with Timeout

Hi,how could one implement a function in concurrent haskell that either returns 'a' successfully or due to timeout 'b'? timed :: Int → IO a → b → IO (Either a b) timed max act def = do Best Regards, Cetin SertNote: the signature of timed can be completely or slightly different. ...

Assigning data-entry tasks to multiple concurrent web-app users

I'm trying to think of an efficient way to allow a group of people to work through a queue of data entry tasks. Previously we've just had one person doing this so it hasn't been an issue. The back-end is an RDBMS and the front-end is a web-application. Currently we do something like this: To assign a record for editing: SELECT * FRO...

What's the best linux kernel locking mechanism for a specific scenario

Hi, I need to solve a locking problem for this scenario: A multi CPU system. All of the CPU's use a common (software) resource. Read only access to the resource is very common. (Processing of incoming network packets) Write access is a lot less frequent. (Pretty much configuration changes only). Currently I use the read_lock_bh, wri...

Multiple AJAX requests on F5

Recently we've found one very strange bug in our application. There is a form for paid message sending. User selects his contact members, groups, enter phone numbers and text message, after that he click on Submit button and we send an AJAX request to validate the form and required account's balance for the operation. If user had selec...

Writing a one-at-a-time lock in Java

Hi. I'm trying to implement a Java lock-type-thing which does the following: By default, threads do not pass the lock. (Opposite from normal locks, where locks can be acquired as long as they are not held.) If only one thread is waiting for the lock, execution in that thread stops If more than one thread is waiting for the lock, the th...

How to make BackgroundWorker return an object.

I need to make RunWorkerAsync() return a List<FileInfo>. How can I return an object from a background worker? ...

Update a count (field) safely in SQL

I want to implement SO like tags on userpost. I have a table called tag_data with columns tagId, title, count. I have a separate table that links the relationship between a post and the many tags it may use. Heres the problem, how do i get the current count, increase or decrease it by one and store it SAFELY. So no other connection/thre...

Dual-queue producer-consumer in .NET (forcing member variable flush)

I have a thread which produces data in the form of simple object (record). The thread may produce a thousand records for each one that successfully passes a filter and is actually enqueued. Once the object is enqueued it is read-only. I have one lock, which I acquire once the record has passed the filter, and I add the item to the back...