0
votes
2answers
24 views

Java paint 'stuttering' -list concurrency

One of my applications paints objects to a screen by reading an array List: simple code summary: @Override public synchronized void paintComponent(Graphics g) { for(Object gO:paintList) { ...
0
votes
1answer
54 views

Make two operations atomic

I'm implementing a custom datastructure that should follow these requirements: Elements should be searchable (i.e., locate and retrieve an element according to .equals()) When I try to retrieve an ...
0
votes
1answer
20 views

Special case of double checked locking?

So I have this code where lockMap is a ConcurrentHashMap //Creation of locks Lock getLock(String key) { Lock lock = lockMap.get(key); if (lock == null) { synchronized (lockMap) { ...
0
votes
4answers
33 views

AsyncTask does not correctly restart in Android

I am developing an Android application and I need show remind dialog from time to time in according to variable from shared preferences. If user does not want to see reminder message, he can disable ...
0
votes
0answers
11 views

Sping social facebook template thread safety

I am currently using Spring Social to access page meta information from Facebook. There appears to be a significant proportion of time (20%) spent initialising the FacebookTemplate object which is ...
0
votes
2answers
57 views

After calling start( ), why does the thread’s constructor returns to main( ), without being the control forwarded to the run() method?

Here is an example that creates a new thread and starts it running: class NewThread implements Runnable { Thread t; NewThread() { // Create a new, second thread t = new Thread(this, "Demo ...
-5
votes
1answer
41 views

System.out.println() statement is not printing (Threads) [on hold]

Can any one tell me why the System.out.println() statement is not working? public static void main(String args[]) throws InterruptedException { HelloBonjour x = new HelloBonjour(); final ...
-3
votes
1answer
29 views

is this gud practice to create thread using runnable thread?

is thisgood practice to creating a new thread inside Runnable? public class ExampleThread Implements Runnable{ public void run() { try { //Some functions } catch (IOException e) { ...
0
votes
0answers
52 views

Android Multithreading with for loop and shared variables

I'm looking through the "Multithreading" Topics all around Google but seem not to being able to understand how exactly the sharing of a variable would work. It's currently not necessary but in future ...
0
votes
0answers
4 views

JBoss 5.1 IdleRemover thread blocking data connection

I am trying to deploy an application war file to JBoss 5.1 but it is stalling. During the JBoss startup the application appears to be attempting to access an Oracle 11g database using a JNDI ...
0
votes
0answers
17 views

Eclipse doesn't run embedded Tomcat shutdown sequence when pressing stop button

Usually, when I hit the stop button from within Eclipse on the embedded Tomcat instance, the current console is swapped with a new, empty, console window. The former console window is still available ...
0
votes
3answers
35 views

Call a method on change of a value

There is a variable called age, int static age = 21; I want to call method onAgeIncreased(){ ........... something...... } whenever the age is changed by any thread in my program (Just like ...
3
votes
1answer
36 views

How can a Thread constructor can accept a run method directly?

I was refering to DeadLock code and saw this website http://www.javatpoint.com/deadlock-in-java I saw the java API, but couldn't find any such Thread Constructor and still wondering how is this ...
1
vote
2answers
28 views

Graceful termination of a Java program and logging of terminate signals

In a Java 8 application running on Linux (CentOS 6), I want to be able to gracefully terminate it and log the type of caught signals (SIGTERM, SIGINT, SIGHUP). private static volatile boolean die ...
1
vote
1answer
22 views

How to check Scanner.hasNext(System.in) with a timeout if nothing is typed?

Scanner sc = new Scanner(System.in); Scanner can be used for reading text files, user input streams, and more. I am specifically using it for reading user input as is made clear above. With the ...
2
votes
2answers
48 views

java - synchronization block on byte[]

I'm familiar with basic java threading mechanism, however, got confused about one particular case. Below is the sample code. static byte[] syncBuf; // synchronized block of code ...
-1
votes
1answer
29 views

AsyncTask error occured while executing doInBackground()

I'm getting an error in following code, calling asyn method for http request. It gives me a java.lang.RuntimeException error inside doInBackground() method. _____________MAIN class____________ ...
-4
votes
0answers
37 views

Memory Allocation Project in Java [on hold]

So I am currently trying to start on this project for my Operating Systems class, and I feel like I'm way in over my head, as I'm sure a lot of computer science majors feel the same. We have been ...
0
votes
2answers
32 views

How to fix non-atomic use of get/check/put?

I have a JSONArray which I am iterating to populate my Map as shown below. My ppJsonArray will have data like this - [693,694,695,696,697,698,699,700,701,702] Below is my code which is having ...
2
votes
2answers
54 views

Synchronize Three Threads

Was asked this question in an interview , tried to solve it ... but not successful. I thought of using CyclicBarrier There are three threads T1 prints 1,4,7... T2 prints 2,5,8... and T3 prints 3,6,9 ...
0
votes
2answers
24 views

Getting a crash on doInBackground() line on client.execute(httpGet). Why?

Crash is: java.lang.RuntimeException: An error occured while executing doInBackground() Why I am getting a crash on the HttpResponse response = client.execute(httpGet); line here? Does it have ...
0
votes
0answers
25 views

Many threads blocked in java.lang.Object.wait() with a two-line stack trace only

From a thread dump taken because the thread count of a web app running in Weblogic was unusually high. Several hundreds of threads showing as below. I'm puzzled by these very short stack traces. What ...
0
votes
1answer
33 views

JFrame not running properly inside a thread

I am trying to run a simple game where there is a server and a client talking to each other to do updates, at the moment I am not doing much between the server and the client just sending some ...
3
votes
2answers
53 views

Why does it matter what object I use wait()/notify() on, if I just want a way to signal between threads?

So I have a classic case of "my code works, but I dont know why". I'm have a program that creates a thread, and when I receive a certain input from scanner, I pass control of the string to a worker ...
3
votes
2answers
53 views

Is the Thread really stop when I use new Thread().interrupt();?

I create a Thread like the following code. This Thread will send the POST request.(The code is not yet written , so I didn't post the detail code of Thread ) final Runnable Update_Value = new ...
0
votes
2answers
53 views

Asynchronous communication between threads in Java

Backstage: I'm practicing in Android development. Trying to make an app that gets some data from remote http server. Android system requires http requests to be done in separate threads. So, I have a ...
-3
votes
1answer
26 views

Are implicit objects in JSP are thread safe? [duplicate]

is implicit objects in JSP are thread safe. in my JSP file, i am checking if session doesn't contain my object then i fetch if from the DB and put it in session. Is this operation thread safe(in ...
0
votes
1answer
47 views

Limit number of active threads/cores a JVM can use [duplicate]

I have a piece of code in Scala (using Java execution context) that spawns many threads. Also I have an 8 core CPU. When the process runs it uses up all the juice my computer has and I cannot do ...
0
votes
1answer
30 views

Java single-threaded multi-user chat program

So I'm working on this recreational project to learn more about java networking and so far every tutorial or documentation I've come across involves creating a new thread for each client connection to ...
1
vote
2answers
61 views

Wait for an actor response indefinitely in a future akka java

I have a non-actor-based piece of code which delegates some operations to an akka actor and I would like to wait this actor response indefinitely, I mean, until this actor returns a response whatever ...
1
vote
4answers
43 views

Java synchronize a class instance

I can't seem to find any example of what I want to ask: Let's say I have in class Account public void transferMoney(Account fromAccount, Account toAccount, DollarAmount amountToTransfer) { if ...
1
vote
1answer
17 views

How to run a fixed interval thread from start of app?

This may be a poorly worded title, but I am trying to gather data and statistics on my application from the very start of it. I am using JavaFX and I have a model class that will be dealing with all ...
0
votes
1answer
22 views

Why the JPA EntityManager isn't thread-safe by definition?

As I know, it is practically a pool, a two-way read & write cache of the persistent JPA entities. I think, this is the typical situation of a class which should be really thread-safe, parallel ...
1
vote
1answer
17 views

EJB forcing single-threaded access to individual members of a resource collection

How, in an EJB environment, can I force interaction with any given resource in a collection of resources to be single threaded, without limiting access to the collection itself? I want to allow one ...
0
votes
1answer
51 views

Synchronizing a group of threads

I am writing a program in Java in where I have a HashMap<String, Deque<Integer>> info; My data is a list of Wikipedia pages that were visited with an hour time period, along with a count ...
0
votes
2answers
79 views

Java threads: how do threads return values

I'm a university student of Computer Science and I am familiar with threads in C. However in Java the OOP makes Threads hard for me to understand. I've written the following program and need to ...
0
votes
0answers
10 views

SolrJ Parallel Indexing from Oracle --> Solr (Java Concurrency - Multi-threading)

My Goal : Copy Data(1 001 000 Rows) from Oracle DB to Solr using SolrJ (everyday). Machine: Intel(R) Xeon(R) CPU E5-2680 0 @ 2.70GHz(Virtual Machine - 8 Thread 16GB RAM) My question aims at the ...
-3
votes
2answers
39 views

Pause loop on user input

If I have a loop like this: for(int i = 0; i <= 10; i++) { System.out.println("Hello, User " + i; Thread.sleep(1000) } How would I go about adding code that did not require user input, ...
0
votes
0answers
28 views

wait and notfiy between two threads [duplicate]

I'm learning Java's multithreading and now trying following: I'd like to have two threads, thread A prints odd numbers only, thread B prints even number only. When thread A finishs output a number, ...
0
votes
1answer
24 views

ProgressBar in Notification [ANDROID]

I know that there are many topic about it. I know that there is the android developer website and even if i use the code from this website i have an error. i just want to put a ProgressBar in the ...
0
votes
2answers
88 views

Processes in Java- Do they work concurrently?

I am executing another java program through a Process object. This takes some time to complete. In the mean time, will the parent program continue running or will it be on hold, to wait for the child ...
0
votes
1answer
24 views

Data sharing (class level) among multiple threads

Need your help to get my basics right. Please consider the following fragment (from a book :) ) class Flooring extends Thread { final int MAX = 100000000; int number; volatile double d = 0; ...
-2
votes
2answers
39 views

ThreadPool quitting upon submit

As soon as I submit a Runnable to the ThreadExecutor, it quits and I can't figure out why. I've traced the code, but to no avail. Does anyone have any idea why this would be? By quits, i mean the ...
1
vote
1answer
50 views

Singleton using “Initialization-on-demand holder idiom”

This question is related to Initialization On Demand Holder idiom. I found here it IS thread safe without a final modifier. I hope this is not a dumb question. I have a configuration singleton that ...
4
votes
4answers
32 views

Thread safety with map and concurrentHashMap

Below are two approaches, both creating instance of concurrentHashMap, my understanding is that approach 2 is thread safe but not approach 1. But am having conversation with colleague and per him, ...
0
votes
1answer
51 views

How to communicate between two threads

I have 2 threads managed by JBoss (without start method). I need that if one of them enters into a loop then the other one has to be able to kill it. In other words, how can I send a message (or ...
1
vote
1answer
36 views

Android - executing different functions with multiple threads

I am pretty new to Android programming but got some experience in other languages. I want to create an APP which is principle working like this. The APP is a process which is asking my ...
1
vote
1answer
50 views

How to remove Non-atomic use of check/put and make the code thread safe?

I have a code from which I am trying to get the instance of my class as I have written a wrapper around java.util.logging.Logger. Below is the snippet of code in my ClientLogger class - private ...
0
votes
0answers
38 views

Java thread-safe multi-variable non-linear minimization library?

I have a non-linear multi-variable minimization problem to solve for a Java program. As shown in the picture (can't attached a picture directly, I provided a link below), the target function to ...
-4
votes
0answers
59 views

Need help implementing Multithreading/making it run faster in java [on hold]

Was wondering if someone could help me implement multithreading into the port scanner I am trying to make. I have little to no experience in writing java, so it would be nice if step by step ...