2
votes
1answer
50 views

Dining Philosophers problem Solution with Java Reentrant Lock

I have implemented Dining Philosopher problem using ReentrantLock in java. The goal of this program is Every philosopher should follow the workflow of think,getchopsticks,eat,putchopsticks (No ...
1
vote
1answer
67 views

Thread safe settings

I'd like to design a settings class thread save. The settings have 2 attributes: String x and int y and should provide listener functionality to notify listener about changes. The problem is, how to ...
0
votes
1answer
28 views

Ensuring my program is thread safe

I have a class which is responsible for waiting until a message is added to a message list and then sending it off to get processed withdrawMessages - waits for message. I wait a total of 2 minutes ...
2
votes
1answer
92 views

Review of simple Java Actor library

How can I improve this code? Also available from git://github.com/edescourtis/actor.git . Actor.java package com.benbria.actor; public interface Actor<T> extends Runnable { public ...
3
votes
2answers
54 views

Is this a scenario to use volatile instead of synchronized?

I want to know if using volatile in this scenario will give a better performance than using synchronization. Specifically for the paused and running instance variable in the SimulationManager class. ...
3
votes
1answer
185 views

Java thread safety and caching techniques

This is my first Java multi-threading code. It is part of an Android application that is a client to a webpage that serves books. Each page of the book is in a separate PDF, and the Book class ...
3
votes
1answer
99 views

Thread Safety issues in the multithreading code

I am working on a project in which I have two tables in a different database with different schemas. So that means I have two different connection parameters for those two tables to connect using ...
2
votes
2answers
85 views

Simple FIFO Job list in Java

For the first time I have to play with Threads in java. Basically, my code is a simple FIFO job queue. The main thread regularly puts jobs in the queue wich need to be executed. The code below is a ...
2
votes
1answer
53 views

BlockingQueue Implemetation using ReentrantLock

I was writing my own implementation of BlockingQueue for practice. I am trying to avoid using the synchronized keyword for the methods. I would instead like to use ReentrantLock. What is the best way ...
1
vote
2answers
324 views

Lock-Free Ring Implementation

I am wondering if someone can take a look at my lock-free, circular ring implementation which I use to implement a background logger. The CircularRing pre-allocates LoggableEntity elements and stores ...
4
votes
2answers
174 views

Multithreading correctly done?

I rarely write multithreaded code, and am on shaky ground when doing so. I make mistakes. I would like a sanity check of something I am going to introduce in one of my apps. There will be exactly ...
3
votes
2answers
115 views

How is this ThreadSafe?

Given the class Sequence: //This method getNext must return a unique value nextValue public class Sequence { @GuardedBy("this") private int nextValue; public synchronized int getNext() { ...
0
votes
1answer
79 views

Thread Safe Server Querier

I wanted to make a class that connects to my server and returns a value, a url in this case. As Android 4.0 doesn't let me run network task on the main UI thread(rightly so) I have made this. Please ...
1
vote
1answer
266 views

Loading an Object from File with Type-Safety and Thread-Safe access

I'm attempting to write a bit of code that allows for easy and safe access to objects in a file. It seems to work great but I was curious if there was an easier way to do this or if Java already has ...
4
votes
1answer
295 views

is this thread safe?

I am using this code for receiving log messages from my clients I receive more than 1000 connections per minute. I want to increase my log handling. I did with java threading. I have a doubt if it ...

1 2
15 30 50 per page