2
votes
1answer
32 views

Efficiently awaiting for resources

I wonder what would be the most efficient solution to this problem. I have a multithreaded database implementation (LevelDB, for example) and I want it to handle synchronization, since it can do it ...
4
votes
3answers
62 views

Lock writes to HashMap

I have a HashMap which is being updated asynchronously. I need to perform operations involving the map which require the map does not change state during the task, for example sorting values based on ...
0
votes
1answer
42 views

Thread program confusion over join

I was going through oracle tutorials on Threads.I found below program a bit confusing.According to me join method is used for a thread to wait until current thread finishes execution.Why are they ...
0
votes
1answer
55 views

Why is Java using more cores than I asked it to?

I have some multithreaded Java code. I know that I spawn three threads. I have six cores, so I expect to see my CPU usage jump between 0% and 50%. However, after adding some new, memory-intensive ...
0
votes
2answers
25 views

How to write to multiple BufferedWriters synchronously

I have a FixedThreadPool that is reading some lines from 2 BufferedReaders and I want to write to a number of BufferedWriters, let's say 50. My question is how do I get the guarantee that the ...
0
votes
1answer
32 views

ScheduledExecutorService and Threads in Java

How does scheduler work here ? Does it create a new thread in the background and execute Run method in the main thread like a callback. ? . When run method is getting executedl, is it belong to the ...
0
votes
3answers
38 views

How to delete rows which have a field greater than 24 hours

I have a table which contains 2 user names and a date - I need a way of processing the table so that when the date stored is greater than 24 hours / 1 day - then it is removed. I am thinking that my ...
1
vote
3answers
39 views

Sequential execution of threads using synchronized

I have a snippet of code that creates 3 threads and expect them to print sequentially using synchronized block on the integer object. But apparently I am getting deadlock sometimes. See below: ...
0
votes
2answers
19 views

Java JProgressBar does not show up by setVisible(true)

I have a method like below. ProgressWindow is a sub class of JFrame containing JProgressBar. addProgress() increments a value in the JProgressBar. If I call this method from a method in another ...
0
votes
1answer
29 views

how volatile keyword Influences atomicity when defining a long or double variable

I'm recently reading the thinking in java,and confused by below: However, you do get atomicity (for simple assignments and returns) if you use the volatile keyword when defining a long or double ...
1
vote
3answers
44 views

Java - synchronize individual elements in primitive array

so I have an array of a lot of ints, and I am writing single bits to it everywhere to store information. Like so: public class myclass { int[] bitArray; //methods public myclass() { ...
0
votes
2answers
41 views

Semaphore synchronized wait() and notify() [on hold]

I have codes below: this is to get knowledge of semaphore. The codes is Thread A first is waiting since b.wait() (making calling thread sleep), then get notified, Why the code has synchronized here? ...
0
votes
0answers
15 views

Access Android NDK App Native Looper

What I'm trying to do: I know that the C++ side of the Android App (Android NDK) is processing all the events that are delivered to it. That works properly. What I'm trying to do is send a message ...
1
vote
4answers
63 views

What is busy spin in a multi-threaded environment?

What is "Busy Spin" in multi-threaded environment? How it is useful and how can it be implemented in java in a multi-threaded environment? In what way can it be useful in improving the ...
0
votes
0answers
24 views

sms send and delivered notify project android

I have a big problem with my project. Basically what my project is designed for: First of all it must be run on old android version, 10 api level.. The app should: take a message from a web service ...
0
votes
1answer
29 views

How to make a runnable thread for my charts?

My program is up and working like I wanted it but now I want to implement Runnable in my program so I could show each tab that my chart runs. How should I do this? I've tried using the methods that I ...
0
votes
0answers
29 views

Android MainActivity thread in a for loop

I just started android dev literally 1 day ago. In the code below, i simply want the For loop to sleep for 5 seconds after every iteration. However, it only runs and prints once. I'm not sure what I'm ...
0
votes
0answers
9 views

Android OpenCV Camera Thread Error

I am trying to use Android camera for object recognition. I am using OpenCV Java for feature extraction. Here is my code: public Mat onCameraFrame(CvCameraViewFrame inputFrame) { // TODO ...
0
votes
3answers
50 views

In Java why Thread class is created as Concrete Class?

We know that there are two ways to create a Thread in Java. Implementing Runnable Interface Extending the Thread Class [Thread is a Concrete Class with defult implementation for run() method] If ...
2
votes
2answers
54 views

Wait for mail sending in another thread to complete

I've got a problem I can't really figure out. I have my main thread, and in it I want to Send an email with an attachment Delete the files that were attached in that order. My problem is that I am ...
0
votes
0answers
9 views

Jersey: immediate Response after asynchronous request

I try to understand the way asynchronous responses work with Jersey. I read chapter 10 of the Jersey documentation (https://jersey.java.net/documentation/latest/async.html) but it doesn't help with my ...
0
votes
3answers
31 views

How to Assign Variable from Thread

I am trying to create a variable to return which indicates whether a thread was successful in doing its job or not - however, it requires the variable be final which means it cannot be re assigned. ...
0
votes
4answers
51 views

How to run a class' method using thread

If I do the following, I will be able to create an object as a thread and run it. class ThreadTest { public static voic main(String[] args) { HelloThread hello = new HelloThread(); ...
0
votes
0answers
15 views

Finding out what thread is blocking the shutdown of a java program wrapped as a prunsrv daemon

I have a server written in Java - (that incidentally uses ZeroMQ in REQ-REP and PUB-SUB patterns.) I am wrapping it as a Windows services using the Apache Commons Daemon (prunsrv/procrun) Trying to ...
1
vote
1answer
55 views

synchronized increment an int value

Why this program doesn`t display 2000 at every execution? I know that I can use AtomicInteger, but I am curious. class Increment extends Thread{ static Integer i=new Integer(0); public void ...
-1
votes
0answers
24 views

Concurrent Random Access of the same Database File

I am trying to implement a Database access module that will support locking mechanism. The Db is actually provided as a file along with a description of its bytes mapping. I first thought of using ...
2
votes
3answers
53 views

Why Thread execution is giving different output?

I was trying to test/learn a few basic things in threading(Java) and came across a simple but confusing output. Following are my classes public class CopyMaster implements Runnable{ @Override ...
1
vote
5answers
56 views

Deadlock when calling two synchronized method

class Downloader extends Thread { private InputStream in; private OutputStream out; private ArrayList<ProgressListener> listeners; public Downloader(URL url, String ...
0
votes
1answer
30 views

Start fragment in landscape mode

Thanks in advance for your help. I'm trying to load one of my fragments which is loaded from a drawerlayout activity in landscape mode by invoking ...
0
votes
1answer
19 views

testing some asynchronous code by polling a probe?

I'm trying to test something that could be considered a messaging server. To make the story short and simple, let say that i have a client that send a message to a server. I want to test the message ...
1
vote
1answer
24 views

Deterministic assignment of tasks to threads using ExecutorService

Given Executor service with a fixed pool of threads, is it possible to guarantee deterministic assignment of tasks to threads? More precisely, assume there are just two threads, namely pool-thread-0 ...
0
votes
3answers
26 views

Objects created in custom Thread run on main Thread

On Android I have a class MyThread that extends Thread. Inside MyThread I declare some Objects and initialize them inside the run() method. The Objects are instances of custom classes that have their ...
0
votes
1answer
22 views

Android SurfaceView UI Thread Not Working

I have got problems with my Android application (Android ANR keyDispatchingTimedOut). I know the reason behind, but I can't solve the problem. My UI thread is probably overloaded and I wondering how ...
0
votes
1answer
20 views

Android Recieve message from long running thread

In the example of a long running thread how do I pass a Message (not a runnable) to the UI Thread? Basically if I do something like: Looper.getMainLooper().sendMessage(myMessage); How do I receive ...
0
votes
2answers
24 views

How can I send udp datagrams from a specific thread?

I'm trying to send some udp datagrams which contain coded audio samples recorded via AudioRecord class. This android class provides a notification when a certain period of recording is elapsed and its ...
2
votes
1answer
49 views

Enable Intel Hyperthreading in Java

I have a multithreaded program running on a quad-core Intel i7. When I execute Runtime.getRuntime.availableProcessors(), I get 8, and I know that hyperthreading is available on this CPU. However, ...
0
votes
0answers
4 views

HtmlUnit Logging in Thread

I am using HtmlUnit in Java threads (runnable) and I constantly getting these warnings: WARNING: Invalid cookie header: "Set-Cookie... and RHINO USAGE WARNING: Missed Context.javaToJS() conversion I ...
2
votes
2answers
38 views

Call to Synchronization/wait?

Could anyone just help me understand this? If we have a class: public class Sample{ public synchronized method1(){ //Line1 .... wait(); //Line2 .... } } Now, when 3 new threads try to call ...
1
vote
2answers
52 views

Starting a Thread with run() instead of start() [duplicate]

I learned that to start a thread the recommended way is to invoke start() method on thread object. But this in turn invokes the run() method. So why not directly invoke run() method? Here's what I ...
1
vote
1answer
81 views

Delegating error from writer thread of PipedWriter+PipedReader pair to the reader thread

What do I want? I have a PipedWriter + PipedReader pair with two threads. I want, that the exception catched in the writer thread would be thrown on the next operation of the PipedReader wrapped into ...
4
votes
2answers
79 views

Memory consumed by a thread

I need to monitor the amount of memory consumed by threads spawned by my application. The idea is to take corrective actions, if a greedy thread consumes too much of memory. I have referred to How ...
-2
votes
1answer
55 views

Exception in thread “Thread-0” java.lang.NoClassDefFoundError

When i try to run following code example it gives me java.lang.NoClassDefFoundError exception.I have take looked at related question. so they didnt fix my problem. Anyone can help? public class ...
1
vote
1answer
32 views

Java Socket Exception: Socket Closed and null value

I want to create server which is able to be connected with multiple clients, but I always get 'Socket Closed' exception or read NULL value from input streams, previously I thought it was caused by ...
1
vote
1answer
45 views

java.io.IOException: Cannot run program “/bin/bash”: error=24, Too many open files

I am connecting wmic via terminal for every 5 seconds by using thread. But I got "java.io.IOException: Cannot run program "/bin/bash": error=24, Too many open files" after 1 day. Thread program: ...
0
votes
1answer
39 views

JavaFX - How to pause a background Service with UI controller event?

With JavaFX UI controller event I want to pause the background Service, service which start with that UI controller (as show on following code). I have found a similar post JavaFX2: Can I pause a ...
0
votes
1answer
15 views

Why am I getting Resources$NotFoundException when updating a TextView?

I am writing a simple stopwatch application for android which will just keep the counter updating each second when pressed start, and pause it with the same button. In my main.xml layout I have a ...
0
votes
0answers
11 views

Android SurfaceView Move Expensive Code/Methods To A Background Thread [on hold]

I have got problems with my Android application (Android ANR keyDispatchingTimedOut). I know the reason behind, but I can't solve the problem. My UI thread is probably overloaded and I wondering how ...
-1
votes
1answer
28 views

java ExecutorService, changing fixedsize

So I want to change the fixedthreadpool size after already declaring it before, how would I go about doing this. I tried this but it doesn't work: ExecutorService pool = ...
2
votes
4answers
70 views

What is the best way to break out of iteration after a specific time?

I am iterating over an Iterator, where hasNext() will never return false. However, after a specified time (let's say 20 seconds), I want to stop iterating. The problem is that the next() method of the ...
0
votes
1answer
8 views

SWT Invalid Thread Access- Mixing up Displays Draw2D

I've got a class that displays a graph using Zest that can be run on its own since it has a main method. However, I'd like to that main method to be run when I select a button in another shell. The ...