Sitemap

Amicuk Programming Answers

How to know if a thread is busy?

-0001-11-30   Views:0

Advertisement

I have a main class and a Thread class that is a client. I need this feature: client receive a data and pass it to main class; main class, by its methods, process this data; during processing, client could receive a new data, but if main class is sti

I have a main class and a Thread class that is a client.
I need this feature: client receive a data and pass it to main class; main class, by its methods, process this data; during processing, client could receive a new data, but if main class is still processing, client must reject.
The question is: how does the client knows if the main class is still elaborating?

The replay answer
Advertisement
In a thread I have put this method:
public synchronized void setIsProcessing(boolean
ean b) {
isProcessing = b;
then in a while I have:
synchronized (this) {}
if (!isProcessing) ....
else .....
I'm calling setIsProcessing from main class when I'm
starting doing anything, but if in a thread arrive
another things, it seems it queues it, and sends to
the main class when main has finished (it seems
isProcessing is never setting to true).
Why?Using the keyword synchronized in a non-static method is implicitly the same as using synchronized(this). If within the second bit of code you have an infinite loop that doesn't release the monitor then setIsProcessing() can never actually be executed by another thread as that requires acquiring the same monitor that you're not releasing.
::The main practical reason for "implements Runnable"
instead
::of "extends Thread" is that Java doens't support
multiple inheritance
:: of classes. So if you extend thread, you can't
extend anything else
:: but if you implement Runnable, yo can extend some
other class.
So, this is the reason of "implements"? Sorry for
this "academic" question ..If by that you mean as a solution to the problems of a single inheritance model then yes.

Go to See the other 15 answers

Stuck Thread - JMS Business proxy Service (ALSB 2.5)

Category:DefaultRelease time:-0001-11-30Views:130

Hi All, We are having a jms proxy service which uses a JMS Business Service to send messages to a jms queue on weblogic 8.1 sp6. The alsb domain runs on weblogic 9.2.The jms proxy service is made single threaded by configuring a suitable work manager[More]

Main thread is busy, cannot receive callbacks

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I'm using the measurement studio activeX control to program my application. (NI-DAQ 6071E) My main thread is always busy because there's a lot of calculating and graphing. I'm using the CWAI control to do continuous caputuring. When the program i[More]

How to know if a thread is busy?

Category:DefaultRelease time:-0001-11-30Views:130

I have a main class and a Thread class that is a client. I need this feature: client receive a data and pass it to main class; main class, by its methods, process this data; during processing, client could receive a new data, but if main class is sti[More]

Best way for a thread to wait without busy-waiting

Category:DefaultRelease time:-0001-11-30Views:130

Hi! I have a thread that has nothing to do but to monitor the status of a variable public static boolean askToClose. This variable is set by other threads to indicate that this thread should stop now. But I don't want the thread to busy-wait like in[More]

Thread count tuning

Category:DefaultRelease time:2015-10-11Views:130

Hi! We are running a weblogic 5.1 server for jsp/servlet/ejb behind an apache web server, via the wls/apache bridge. As the number of users increased we expereienced slow response times. We checked thread dumps from peak hours and saw that all servle[More]

Applet UpCall from JS Event - Which Thread? Options

Category:DefaultRelease time:-0001-11-30Views:130

Hi, With many direct references to the second lovely colour diagram on this page: - http://java.sun.com/javase/6/docs/technotes/guides/jweb/applet/applet... I completely understand the hour-glass pause on the single-JS-thread preservation architectur[More]

How to terminate/destroy a user thread running in background?

Category:DefaultRelease time:-0001-11-30Views:130

Hi All! I m using t.destroy() to stop a background running thread, as t.stop() is depricated in Java 2. I implement Runnable in the background thread. On calling t.destroy() NoSuchMethodException; don't know whats the problem there?I still don't see[More]

Business One Trial???

Category:DefaultRelease time:-0001-11-30Views:130

Where can I find a trial version download of Business One for windows so I can learn it before implementation??? Thanks...Hi, Check thread => SAP Business One Trial Version May it will help you. Thanks and Regards, Faisal Edited by: Faisal Altaf on D[More]

Difference between business area balance sheet and profit centre accounting

Category:DefaultRelease time:-0001-11-30Views:130

Hi all, I want to know what are the differences between business area balance sheet and profit centre accounting. Please tell the merits and demerits of both. If, I want to get plant-wise profitability of a company then which method is more recommend[More]

Do we need a SAP Business One & Business Objects Forum?

Category:DefaultRelease time:-0001-11-30Views:130

Hi all, We have made the Crystal Reports Add-on for SAP Business One available in the [Knowledge Center|https://www.sdn.sap.com/irj/sdn/businessone?rid=/webcontent/uuid/807d22cb-cb1d-2b10-8794-fb76d7feca88] For all discussions arround SAP Business On[More]

Business Place by default in MIRO based on PO

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I have a requirement where I need to default a value in the business place (BUPLA) field in MIRO based on the site(plant) in the PO. please help me how to achieve this. thanks in advance, kumarHi Kumar, i feel that you might need ABAP help to ach[More]

Hot
after doing an apple update, my ipad will not respond, all i get is the itunes plug in.  I want to make sure to restore everthing that was on my ipad?The iTunes and plug icons are telling you that the iPad is in recovery mode. Connect the iPad to the [More]
Few weeks ago we have added new Exchange 2013 SP1 onto our existing Exchange 2007 environment. I have migrated my mailbox to the new Ex2013 server. Everything (send/receive - internally/externally, OWA, OutlookAnywhere) for me and the existing Ex2007 [More]
Is it possible to play f4V files in Acrobat?  Using the flash tool I have included an F4V file but the video will not play.  Are there complatibility issues? Any ideas? Thank You, MelanieMelanie, Did you find a solution to the F4v issue?Read other 2 [More]
I would like to know how to run AHT (Apple Hardware Test) on my MacBook Pro 4,1 (early 2008) because I tried to follow the Apple support but I am not sure what to do. I updated my Mac to OS X 10.9 but I still have the original disks of Leopard 10.5 T [More]
I purchased the season pass for prison break season 4 a month ago but am unable to download episode 7. when i click on check for check for available downloads it says that there are none. episode 7 just came out and I do not have it in my library. Th [More]
hi , i upgraded my iphone with ios 5 , i had a lot of contacts before i did that , now when someone from my contacts calls i don't get the name of the caller though its stored already on my phone , someone told me that i have to re-save my contacts a [More]
Hello Everyone, I hope you can help me with a challenge I am having. Currently I have Sophos Anti-Virus Home Edition version 9.2.4 on my Mac (OS X Yosemite 10.10.3) Reason for the post is I have a virus (Mal/Phish-A) that keeps coming up and I am not [More]
Hey everyone, I've got an interesting problem at my hand that I can't seem to find a reasonable answer to. The issue is as follows: We are in the process of activating BI content ( our ERP has enhancement pack 1 ) and there are a couple of core datas [More]
I have a mac pro 8 core 2nd gen machine (August 2007) just updated from 10.5.2 to 10.5.3 and immediately after doing so the machine usually will not shut down by it self. It goes through the shut down process, exits finder but then the grey spinning [More]
I have Photoshop CS6 Extended. I just want to do something like this. http://prntscr.com/2tk258 However, when I swipe across the text, NOTHING happens. I've been tearing my hair out for the past hour trying to find a reason and I am not able to. Here [More]