Linked Questions

2 votes
1 answer
4k views

I am calling a method CreateOne from Non-Activity class and CreateOne method needs to return an Object after Task execution. So I have addded the below line after calling the Task. task.wait(); But ...
user avatar
0 votes
1 answer
2k views

I've writing a program using HiveMQ Client (an MQTT Open source implementation in Java) that involves using two multithreaded clients. One client is designated as the publisher and the other as the ...
TheDev88's user avatar
  • 345
59 votes
2 answers
120k views

I don't completely understand how wait and notify (of Object) work, and as a result I'm forced to slim down my attempts into the following section of code. Main.java: import java.util.ArrayList; ...
skeggse's user avatar
  • 6,363
3 votes
3 answers
2k views

I have a waiting thread: synchronized(sharedCounter) { while(sharedCounter > 0) { sharedCounter.wait(60000); //wait at most 1 minute /*if it wakens from the end of the timeout, it should ...
Kami's user avatar
  • 1,109
4 votes
1 answer
9k views

In my Android app I am trying to execute a task every 5 seconds. I tried doing something like this: @Override public void onCreate() { //standard initialization code letsChange(); ...
g33k's user avatar
  • 45
4 votes
4 answers
1k views

I have a problem showing a progress dialog with an AsyncTask: Activity has leaked window com.android.internal.policy.PhoneWindow$DecorView{8cee959 V.E...... R......D 0,0-1026,252} that was ...
Droide's user avatar
  • 1,859
3 votes
1 answer
1k views

Say we create a thread which runs a synchronized method. This method tries to take() from an empty blocking queue. Now let a separate thread then try to put() and element onto the blocking queue while ...
nolanar's user avatar
  • 33
0 votes
1 answer
2k views

I am trying below code to reboot my mobile bt_viewpakageroot.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { ...
demo's user avatar
  • 712
0 votes
1 answer
1k views

I have a thread: class SomeRunnable implements Runnable { @Override public void run() { while (true) { //some code... try { Thread.sleep(33); ...
Guy Sharon's user avatar
3 votes
1 answer
704 views

I'm using AsyncTask to pull data from my firebase and it works, however I'm using an empty while loop to ensure my database finishes it's operation before the Task moves on to the next step. I know in ...
Remixt's user avatar
  • 607
0 votes
1 answer
729 views

I have Character and a Monster, and want to simule a battle. To do so, I created two threads, one with the character's attack, and another with the monster's attack. Character and monster has ...
IIRed-DeathII's user avatar
1 vote
1 answer
353 views

I start 2 threads to receive messages in different pages (A and B) but cannot let one wait successfully. Here is the code of the receiveMsg thread. //BufferedReader brClient = new BufferedReader(new ...
nor1take's user avatar
0 votes
0 answers
239 views

I have two threads running t1 and t2. When t2 notifies t1, immediately t2 should go to wait state. However, this is not possible as once it notifies t1, it should finish its current process and only ...
Struse's user avatar
  • 75
0 votes
2 answers
124 views

I have the following code: public class ThreadA { public static void main(String[] args){ ThreadB b = new ThreadB(); b.start(); synchronized(b){ try{ b.wait(); ...
MWO's user avatar
  • 2,846
0 votes
1 answer
88 views

According to the documentation for ReentrantLock.newCondition(), the calling thread needs to own a lock before calling a signaling method: If this lock is not held when any of the Condition waiting ...
Suvam Roy's user avatar
  • 953

15 30 50 per page