2
votes
2answers
28 views

Java threads, keep same number of threads running

I need to process 80 files of info, and im doing it via groups of 8 threads, what i would like to do is to to always have 8 threads running (right now i have 8 threads, and after those 8 finish their ...
1
vote
2answers
54 views

How to stop my program from eternally waiting? (wait/notify multithreading issue)

I have three classes, one that is meant to represent a pile of urls private Queue<String> queue = new LinkedList<String>(); public Queue<String> getQueue() { return ...
0
votes
1answer
44 views

how to make priority in java thread

I am trying to give priority to thread b but it's not working still sometimes print thread t before b the priority does not work, I am not sure about the code any help please ! public static void ...
0
votes
2answers
30 views

thread.getState()

I am new to using threads, and I'm trying to figure out a way to tell if a thread is terminated, as well as gather some information from the thread. However, I'm getting a null pointer exception ...
0
votes
0answers
31 views

blackscreen on android (infinite loop)

I'm trying to create a network monitoring app in android, and it's giving me black-screen problems. I understand that the problems is due to my infinite loop, but the log cat stack-trace is not giving ...
-3
votes
1answer
30 views

IllegalMonitorStateException while handling threads

I am trying to simulate following situation: Every athlete must wait till the Gunner does not make a shot, and when Gunner makes a shot, all athlete should start running. Gunner and athletes, both are ...
1
vote
4answers
85 views

Why increasing number of threads is useless?

I've been looking for the way to increase the speed of processing messages received from rabbitmq queue. The only way I've found is make more than one threads doing the same - receiving and ...
-2
votes
1answer
41 views

List of currently running threads

I was looking for a solution to get the amount of threads running in my program. I ended up with this two solutions from Get a List of all Threads currently running in Java. Using Set<Thread> ...
2
votes
3answers
32 views

Calling interruptible blocking methods in a loop

This question is from an example from the book "Java concurrency in Practice" by Brian Goetz, Chapter 7 , 7.1.3 Responding to interruption (page 143 - 144) It says in the book Activities that do ...
4
votes
2answers
68 views

Getting and Setting a Flag variable in a thread

I am interfacing with a JNI that allows me to use a fingerprint scanner. The code I have written takes the scanned ByteBuffer parsed back to it by the JNI and turns it into a BufferedImage for saving. ...
0
votes
0answers
111 views

Java threads on LINUX

I have a java program which computes Dijkstra's algorithm many times over a graph. I have used threads in java to convert the sequential program to a parallel program for speed up in execution time. I ...
0
votes
0answers
17 views

Remote debugging threads with different debuggers

I have an application which is scheduler running different threads. The application may load new Runnable classes and run them. Currently the application is in production, that is it's running on ...
0
votes
1answer
31 views

Start mulitple tasks using ScheduledExecutorService and remove a task at run time

This is what structure of my code looks like Class TaskA implements runnable { void run() { if(not leader node) { exit this task; (never run it again) } ...
-1
votes
2answers
41 views

Symbol tasks can not find. in java threading

i have two classes. tasks.java is successfully compiled. i do not know how to include tasks.java into another class I am getting error Symbol tasks not find while compiling the cs508.java ...
1
vote
2answers
33 views

Reordering in case two synchronized block and multiple volatile read/write

Consider the below case Case 1: action#1 volatile read var 1 volatile write var 1 volatile read var 2 volatile write var 2 action#2 What can we say about reordering of action#1 with action#2 ...
2
votes
3answers
55 views

Why doesnt the JVM terminate in this case?

I think I have a thread leak in my code, but I am not sure why. Here is the code - foo(String solutionFileName, String SubmissionFileName){ ExecutorService e = Executors.newFixedThreadPool( ...
3
votes
2answers
66 views

Static synchronized methods

I understand that Java instance synchronized methods can run parallel and the static ones will serialize the methods; my lack of understanding is, since the static method locks the Class object, what ...
1
vote
1answer
21 views

Android Ping command dies on unreachable server

I have been trying to attempt to insert a ping command thread into my Android application, and when the server is reachable the code works great. When the server is unreachable, the process hangs and ...
0
votes
0answers
36 views

When does Java's InterruptedException occur? [duplicate]

I know how to interrupt a thread and why you might want to do so, but when does this practically happen? In specific, I have some code where I make a little thread pool using Futures and Callables ...
1
vote
3answers
49 views

Volatility and thread safety in Java

please take this very simple example: volatile int globalVar = 1; My thread: if (globalVar > 0) { globalVar--; } Now, I have to decide whether making the variable volatile is sufficient ...
0
votes
1answer
20 views

Multiple AnimationDrawables at the same time

Is it possible to generate 2 animationdrawables at the same time? I tried it with threads: Thread t1 = new Thread(){ public void run(){ runOnUiThread(new Runnable() { public void run() ...
0
votes
1answer
24 views

Extracting exceptions from a ScheduledExecutorService

I have a scheduled executor whose function connects to the internet and has the potential to throw and exception. This executor is part of an SDK I am developing, and the exception must be thrown to ...
0
votes
3answers
51 views

Java Synchronization -IllegalMonitorStateException

Am I not using synchronization properly: In following code i am having 2 problems : 1. while makingmethods (designBusiness,createBusiness,sellBusiness) as synchronized like in this case, a call to ...
0
votes
4answers
43 views

Set id on Runnable

How can I set id on Runnable in this code Runnable rd = new Runnable() { @Override public void run() { populatePanel(referList.get(handler.getPosition()), handler.getPosition()); ...
0
votes
1answer
37 views

Android Long Running Task Without AsyncTask

I need to implement a logging service in my app that will write logs to my own log file. So far, I decided I will use the singleton pattern to have a wrapper class that will post logs to some form of ...
1
vote
3answers
60 views

IllegalMonitorStateException in code

class Test { public static void main(String[] args) { System.out.println("1.. "); synchronized (args) { System.out.println("2.."); try { ...
0
votes
2answers
40 views

Implementing Multiplex(Concurrency) in Java

Question :- Using Java how will you allow multiple threads to run in a critical section at the same time, but with an upper limit say 6. Not more than 6 threads should access the thread at the same ...
0
votes
3answers
79 views

Threads in Java max amount?

So I'm making a Java Server for a game I'm making and I was wondering if creating a thread for each player is an overkill, having in mind the server might take a high number of people online at the ...
3
votes
2answers
43 views

Java final field compile-time constant expression

The below text is from jls http://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html#jls-17.5.3 Even then, there are a number of complications. If a final field is initialized to a compile-time ...
0
votes
1answer
44 views

Serialization, Cloning and Immutability

We know that new JMM gives guarantees for not seeing partially constructed object or different values of its fields, if all fields are declared final. But we can very well serialize and deserialize ...

1 2 3 4 5 327
15 30 50 per page