2
голосов
3ответов
869 просмотров

How should I make my hashtable cache implementation thread safe when it gets cleared?

I have a class used to cache access to a database resource. It looks something like this: //gets registered as a singleton class DataCacher<T> { IDictionary<string, T> items = GetDataFromDb(); //Get is called all the time from zillions of threads internal T Get(string ke...

1
голосов
5ответов
253 просмотров

Concurrency issues while accessing data via reflection in C#

I'm currently writing a library that can be used to show the internal state of some running code (mainly fields and properties both public and private). Objects are accessed in a different thread to put their info into a window for the user to see. The problem is, there are times while I'm walkin...

7
голосов
4ответов
7536 просмотров

Java multithreading reading a single large file

What is an efficient way for a Java multithreaded application where many threads have to read the exact same file (> 1GB in size) and expose it as an input stream? I've noticed that if there are many threads (> 32), the system starts to contend over I/O and has a lot of I/O waits. I've co...

3
голосов
2ответов
997 просмотров

JPA cache up-to-dateness with concurrent access to the database

A service tier that implements its persistence based on JPA can profit hugely from the second-level cache that is managed transparently by the JPA provider (e.g. Hibernate, Toplink/Toplink Essentials etc.). When this cache is activated, it holds instances of the persistent classes as soon as they...

2
голосов
2ответов
1048 просмотров

Scalability implications of converting stateless session beans to POJOs

Imagine a heavily-used service object that's implemented as an EJB 2.1 SLSB, and that also happens to be thread-safe in itself by virtue of having no state whatsoever. All its public methods are transactional (via CMT), most simply requiring a transaction, but some requiring a new transaction. I...

49
голосов
6ответов
74788 просмотров

.NET Asynchronous stream read/write

I have been trying to solve this "Concurrent Programming" exam exercise (in C#): Knowing that Stream class contains int Read(byte[] buffer, int offset, int size) and void Write(byte[] buffer, int offset, int size) methods, implement in C# the NetToFile method that copies all data received fro...

39
голосов
13ответов
27484 просмотров

Bash: limit the number of concurrent jobs?

Is there an easy way to limit the number of concurrent jobs in bash? By that I mean making the & block when there are more then n concurrent jobs running in the background. I know I can implement this with ps | grep -style tricks, but is there an easier way?

2
голосов
2ответов
1002 просмотров

SynchronousQueue fairness

I'm using a 1producer-1consumer design in my app using a SynchronousQueue. By now, I'm using it with the default constructor (fair=true). And I'm wondering about how "fair=false" would affect to the system (performance and specially concurrency behaviour). Here what the docs tell: Synchr...

12
голосов
7ответов
3155 просмотров

Getting starting with Parallel programming

So it looks like multicore and all its associated complications are here to stay. I am planning a software project that will definitely benefit from parallelism. The problem is that I have very little experience writing concurrent software. I studied it at University and understand the concepts a...

3
голосов
5ответов
7009 просмотров

Servlet concurrency/synchronization in Tomcat?

Is there a recommended way to synchronize Tomcat Servlet instances that happen to be competing for the same resource (like a file, or a database like MongoDB that isn't ACID)? I'm familiar with thread synchronization to ensure two Java threads don't access the same Java object concurrently, but ...

1
голосов
1ответов
1180 просмотров

mysql isolation levels

I'm a bit confused by the documentation here. I have a transaction, which start transaction does some updates does some selects does some more updates commit I want my selects at step 3 to see the results of updates in step 2 but I want to be able to roll back the whole thing. read commit...

13
голосов
2ответов
5007 просмотров

Avoiding multiple repopulations of the same cache region (due to concurrency)

I have a high traffic website and I use hibernate. I also use ehcache to cache some entities and queries which are required to generate the pages. The problem is "parallel cache misses" and the long explanation is that when the application boots and the cache regions are cold each cache region i...

17
голосов
2ответов
16725 просмотров

Why does Executors.newCachedThreadPool throw java.util.concurrent.RejectedExecutionException during submit

Number of tasks (threads) submitted is also not huge in this test scenario.

22
голосов
5ответов
15291 просмотров

ScheduledExecutorService with variable delay

Suppose I have a task that is pulling elements from a java.util.concurrent.BlockingQueue and processing them. public void scheduleTask(int delay, TimeUnit timeUnit) { scheduledExecutorService.scheduleWithFixedDelay(new Task(queue), 0, delay, timeUnit); } How can I schedule / reschedule the...

1
голосов
3ответов
576 просмотров

Linux: Is this a correct way to run scripts in parallel?

I want to update a large amount of SVN-versioned projects at once, using a script. It takes very long when running update jobs one by one. So I tried to run the jobs in parallel. It seems to work, however I'm not sure if it's done correctly. Perhaps there are concurrency issues I didn't think of...

19
голосов
4ответов
124917 просмотров

How to check if a table is locked in sql server

I have a large report I am running on sql server. It takes several minutes to run. I don't want users clicking run twice. Since i wrap the whole procedure in a transaction, how do I check to see if the table is locked by a transaction? If so I would want to return an error message saying "report ...

0
голосов
1ответов
148 просмотров

How do I get visual studio to not wait on temporarily blocked tests?

I'm relatively new to unit testing, and trying it on my personal projects. I want to unit test some concurrent methods (futures which run actions in the thread pool). To avoid the test method finishing before the thread pooled action, I'm blocking the test. Here is the actual blocking code: Priv...

71
голосов
4ответов
40591 просмотров

Log output of multiprocessing.Process

Is there a way to log the stdout output from a given Process when using the multiprocessing.Process class in python?

5
голосов
2ответов
3859 просмотров

How to Tell if a Thread Pool is Idle in Java

I have a thread pool created using java.util.concurrent.ThreadPoolExecutor Is there anyway I can wait till the pool is idle? By which I mean all the threads are not running and nothing is waiting in the queue. I searched the web and all the solutions don't work for me. For example, I don't...

6
голосов
4ответов
2728 просмотров

Linq caching data values - major concurrency problem?

Here's a little experiment I did: MyClass obj = dataContext.GetTable<MyClass>().Where(x => x.ID = 1).Single(); Console.WriteLine(obj.MyProperty); // output = "initial" Console.WriteLine("Waiting..."); // put a breakpoint after this line obj = null; obj = dataContext.GetTable<MyClass&...

3
голосов
3ответов
3074 просмотров

Why would invokeAll() not return?

I have roughly this code: ExecutorService threader = Executors.newFixedThreadPool(queue.size()); List futures = threader.invokeAll(queue); I debug this and invokeAll doesn't seem to return until all the threads in the Queue are finished. Any reasons why this is happening.

2
голосов
2ответов
620 просмотров

How to manage object life time using Boost library smart pointers?

There is a scenario that i need to solve with shared_ptr and weak_ptr smart pointers. Two threads, thread 1 & 2, are using a shared object called A. Each of the threads have a reference to that object. thread 1 decides to delete object A but at the same time thread 2 might be using it. If i ...

2
голосов
5ответов
490 просмотров

How to build a server that can handle 20.000 concurrenct connections?

It's hard for me to go into exact detail on what the server needs to do (due to NDAs and what not), but it should be sufficient to say that it needs to handle a lightweight binary protocol with many concurrent connected users, ~20.000 is where we have a pretty decent estimate. Note that clients ...

3
голосов
2ответов
4165 просмотров

Java email sending queue - fixed number of threads sending as many messages as are available

I'm writing a message processing application (email) that I want to have an outgoing queue. The way I've designed this is having a singleton queue class, ThreadedQueueSender, backed by an Executor Service and a BlockingQueue. Additionally, a thread pool of javax.mail.Transport objects is used to ...

57
голосов
6ответов
42366 просмотров

How are mutexes implemented?

Are some implementations better than others for specific applications? Is there anything to earn by rolling out your own?

341
голосов
17ответов
278518 просмотров

SET NOCOUNT ON usage

Inspired by this question where there are differing views on SET NOCOUNT... Should we use SET NOCOUNT ON for SQL Server? If not, why not? What it does Edit 6, on 22 Jul 2011 It suppresses the "xx rows affected" message after any DML. This is a resultset and when sent, the client must proce...

1
голосов
1ответов
1481 просмотров

MySQL: Correctness in the face of heavy concurrency (SELECT ... FOR UPDATE)

I'm running a website where users can adopt virtual pets. There is a per-user adoption limit on each pet. So, for example, you can adopt one of our pets a maximum of 10 times. At the moment we do something like this: CREATE TABLE `num_adopted` ( `petid` int(11) NOT NULL, `userid` int(11) NOT...

2
голосов
2ответов
372 просмотров

How can I allow concurrent reads but block all access during a write on an object in Java?

If I have a data structure in a multithreaded application that I want to access simultaneously with reads while it's not altered, but disallow both read and write access to other threads while one is writing? For simplicity, let's say I have an array and two methods read() and write(): int[] rg...

6
голосов
1ответов
5390 просмотров

Performance of concurrency in Django (apache2 prefork/mod_wsgi), what am I doing wrong?

First of all I am not in any way unhappy with the performance of my Django powered site, its not getting massive traffic, a bit over 1000 visits per day so far. I was curious how well it would cope with heavy traffic peaks so I used the ab-tool to do some benchmarking. I noticed that the perfor...

6
голосов
2ответов
16926 просмотров

How do you configure WorkManagers in WebLogic 10.3?

I would like to use a WorkManager to schedule some parallel jobs on a WebLogic 10.3 app server. http://java.sun.com/javaee/5/docs/api/javax/resource/spi/work/WorkManager.html I'm finding the Oracle/BEA documentation a bit fragmented and hard to follow and it does not have good examples for usin...