Thread yield() and sleep()
what is the different bettween yield() and sleep() method
in thread
i think sleep() method make the called thread to wait then
make the way to enter any other
but yield() also do same but dont allow lower priority threads
allow only higher priority thread.
is this correct?
Thread.yield() is used to give other threads a chance to get a processor time slice, according to the thread dispatcher rules. If there are no other threads ready to run, the current thread will gain the processor again.
Thread.sleep() will always release the processor for at least the amount of time specified, even if there are no other threads requesting it.
Similar Messages
-
Thread.yield() and Thread.sleep(), what's the difference
Folks'es,
can anyone enlighten me, as to the difference between yield() and sleep() in the Thread class?
i know, with sleep, one can specify the amount of time to sleep, but does that mean the thread yields for that amount of time?
if i use yield(), how long will my thread stop running?
any information is appreciated
thomasThread.yield() is used to give other threads a chance to get a processor time slice, according to the thread dispatcher rules. If there are no other threads ready to run, the current thread will gain the processor again.
Thread.sleep() will always release the processor for at least the amount of time specified, even if there are no other threads requesting it. -
Hello!
I have some questions.
In the code below i use sleep instead of yield to make it look like both threads are executing at the same time because the yield function does not have that effect on a unix system.
It works even thougt i just sleep for 0 milliseconds. Is it correct to do it this way or are there any problems with it. I guess the program will be slower if i sleep for ie 50 ms.
Lets assume that i have two processors. Is it then unneccesary sleep?
Why does the yield function not work on sun os?
class Threads
public static void main(String[] args)
Thread1 t1 = new Thread1();
Thread2 t2 = new Thread2();
Thread thread1 = new Thread(t1);
thread1.start();
Thread thread2 = new Thread(t2);
thread2.start();
class Thread1 implements Runnable
synchronized public void run()
for (int i = 0; i < 10; i++)
System.out.println("Thread1");
try
Thread.sleep(0);
catch (InterruptedException e){}
//Thread.yield();
class Thread2 implements Runnable
synchronized public void run()
for (int i = 0; i < 10; i++)
System.out.println("Thread2");
try
Thread.sleep(0);
catch (InterruptedException e){}
//Thread.yield();
}The rules for threads don't state that threads of equal priority will be dispatched in a round-robin fashion, its strictly first come, first served, so if your initial thread is always ready to go again, yield may well not release control to the other thread. sleep - even sleep(0) apparently pauses the action long enough that the other thread is the only one despatchable and off it goes.
As hiwa mentioned, as soon as you have real logic in each thread this issue will probably go away. -
Guys,
Based on the definition of Thread.yield
yield() function causes the currently executing thread object to temporarily pause and allow other threads to execute.
But how if "Thread1" (just for name of the Thread) calls Thread.yield() and at that time I only got one thread (Thread1 only), will this thread stop for awhile also?
ThanksI don't really understand what you are asking but stay away from Thread.yield, you can't test the performance of such code because it will be dependant on the jvm implementation. As Joshua Bloch says in Effective Java - "The only use that most programmers will ever have for Thread.yield is to artificially increase the concurrency of a program during testing". Think of Thread.yield as just a hint to the scheduler.
Edit: If you are asking what will happen when you call yield on the currently executing thread with no other threads to execute - you will likely get control back immediately. -
Can anyone introduce me a tutorial on "yield" and "interrupt" of Thread?
Hello, everyone!
I am learning JAVA Thread. I have read all the parts of section "Threads: Doing Two or More Tasks at Once (Essential Java Classes) " of the tutorial "The JAVA Toturial" on java.sun.com but failed to find anything about the usage of functions "yield" and "interrupt".
Can anyone introduce me some tutorials or simple source codes dealing with the usage of the two functions?
Thanks in advance,
Georgeyield is used when you want to let another thread run. Its particularly useless as the scheduler will handle this anyway. Its especially useless in a JVM where the behavior of the scheduler is unpredictable. In a language such as c/c++ where it only runs in one place generally, you can understand the scheduler and help it a bit with yield, but in Java you really do not know for sure where your code will run, and any improvements yield will bring probably can be directed toward inefficiencies in the Thread scheduler of the jvm.
interrupt is basically a request. It only works on certain methods that are checking for it. So you can't have your thread doing just anything and think you can "interrupt" it. For instance, if you are blocking on a socket operation, interrupt will probably not do anything. -
How do i run two threads with different sleep times?
How do i run two threads with different sleep times?
Ive got thread A and thread B, they both update a jpanel.
They both start when i press the start button.
However thread A updates every 250ms and thread B updates every 1000ms. i cant just run them both at 250ms becuase this will mess it up.
So for every four runs of thread A i want thread b to only be run once
Does anyone know how to do this?
Thanks, Ant...ok, ive done it but now i cant stop it!
ive added buttons to start and stop, the start button works but the stop button doesnt. why doesnt "t.stop();" work?
public void run() {
while(t == Thread.currentThread()) {
System.out.println("No " + t.getName());
if (t.getName().equals("1")){
try {
t.sleep(1000); // in milliseconds
} catch (InterruptedException e) {}
} else{
try {
t.sleep(250); // in milliseconds
} catch (InterruptedException e) {}
} -
Why are the threads start and terminate randomly?
Hi there,
I got the program below. I am wondering why are the threads start and terminate randomly? Everytime, I run the program, it produces different results.
I know that these four threads have got same normal priority (should be 5), and under windows there is something called timeslice. Then these four threads rotate using this timeslice. How do we know what exactly the timeslice is in seconds? If the timeslice is fix, then why the results are ramdom?
Thanks in advance!
* To change this template, choose Tools | Templates
* and open the template in the editor.
package mythreadone;
* @author Administrator
public class MyThreadOne implements Runnable {
String tName;
Thread t;
MyThreadOne(String threadName) {
tName = threadName;
t = new Thread(this, tName);
t.start();
public void run() {
try {
System.out.println("Thread: " + tName);
Thread.sleep(2000);
} catch (InterruptedException e) {
System.out.println("Exception: Thread "
+ tName + " interrupted");
System.out.println("Terminating thread: " + tName);
public static void main(String args[]) {
// Why are the threads start and terminate randomly?
new MyThreadOne("1");
new MyThreadOne("2");
new MyThreadOne("3");
new MyThreadOne("4");
try {
Thread.sleep(10000);
// Thread.sleep(2000);
} catch (InterruptedException e) {
System.out.println(
"Exception: Thread main interrupted.");
System.out.println(
"Terminating thread: main thread.");
1. Firstly, I set in the main function:
Thread.sleep(10000);
and I run the program it gives:
Thread: 1
Thread: 4
Thread: 2
Thread: 3
Terminating thread: 1
Terminating thread: 3
Terminating thread: 4
Terminating thread: 2
Terminating thread: main thread.
BUILD SUCCESSFUL (total time: 10 seconds)
Run it again, it gives:
Thread: 2
Thread: 4
Thread: 3
Thread: 1
Terminating thread: 2
Terminating thread: 1
Terminating thread: 3
Terminating thread: 4
Terminating thread: main thread.
BUILD SUCCESSFUL (total time: 10 seconds)
And my question was why it outputs like this? It suppose to be:
Thread: 1
Thread: 2
Thread: 3
Thread: 4
Terminating thread: 1
Terminating thread: 2
Terminating thread: 3
Terminating thread: 4
Terminating thread: main thread.
BUILD SUCCESSFUL (total time: 10 seconds)
Why these four threads start and finish randomly each time I run the program? I use Windows, suppose there is a timeslice (i.e. 1 second), these threads have the same priority. Then the threads should start and finish in turn one by one. Am I right?
2. My second question is:
When I change the codes in the 'main' function into:
Thread.sleep(10000); -> Thread.sleep(2000);
it gives me the results like:
Thread: 1
Thread: 4
Thread: 3
Thread: 2
Terminating thread: main thread.
Terminating thread: 1
Terminating thread: 4
Terminating thread: 3
Terminating thread: 2
BUILD SUCCESSFUL (total time: 2 seconds)
Run it again:
Thread: 1
Thread: 2
Thread: 3
Thread: 4
Terminating thread: 3
Terminating thread: main thread.
Terminating thread: 4
Terminating thread: 2
Terminating thread: 1
BUILD SUCCESSFUL (total time: 2 seconds)
I tried several times. The main thread always terminates before or after the first child thread finished.
My question is why it doesn't output something like:
Thread: 1
Thread: 2
Thread: 3
Thread: 4
Terminating thread: 3
Terminating thread: 4
Terminating thread: 2
Terminating thread: main thread.
Terminating thread: 1
BUILD SUCCESSFUL (total time: 2 seconds)
or
Thread: 1
Thread: 2
Thread: 3
Thread: 4
Terminating thread: 3
Terminating thread: 4
Terminating thread: 2
Terminating thread: 1
Terminating thread: main thread.
BUILD SUCCESSFUL (total time: 2 seconds)user13476736 wrote:
Yes, my machine has multi-core. Then you mean that if I got a one core machine the result should always be:
Thread: 1
Thread: 2
Thread: 3
Thread: 4
Terminating thread: 1
Terminating thread: 2
Terminating thread: 3
Terminating thread: 4
Terminating thread: main thread.
BUILD SUCCESSFUL (total time: 10 seconds)
???No.
>
How to explain my second quesiton then? Why the main thread always terminates before some of the child threads end? Thanks a lot. -
Why does that entire thread goes to sleep when we put a wait function in time critical loop?
why does that entire thread goes to sleep when we put a wait function in time critical loop but not when it is not time critical
Norbert B wrote:
Ujjval,
in a RT system, priorities have (in general) increased effect on the execution of the application.
It is recommended that you only have a single task in your RT program at "time critical". If you have two task "time critical" (that means you are running into issues caused by your quoted "feature"), you have a flaw in your application architecture.
Since LV 7.1, it is recommended to work with Timed Loops in order to prioritize tasks on a RT system. Timed Loops are executed on priorities between "time critical" and "above normal". Each Timed Loop will execute its content in a single thread in order to keep a good overview of the timing (like finished late [i-1]). Using those structures (and according settings) in a reasoned manner will prevent your RT system to run into priority issues.
Ujjval Shah wrote:
[...]also i would really appreciate if i can get more documentations regarding how LV creates threads and assigns subvis to them[...]
You will have a real hard time to go into this very deep. This is the feature of LV: you can just use multithreading (multicores) without the needed knowledge of scheduling and load balancing. This makes LV programming in general very easy in comparison to e.g. ANSI C (in regard of multithreading). So creation of threads, distribution of tasks to the threads are abstracted and most often not visible to the programmer.
There are some switches and levers you can "play around" in order to make LV to behave differently in this matter. But this most often requires deep LV knowledge and cannot be explained in a simple posting.....
hope this helps,
Norbert
Amen to that!
The question can not be fully answered without digging into the internals of the OS LV is run on because LV works with the OS and lets it do the scheduling.
Yes that note applies to pre- LV 7 RT. When run under RT the ONE Time Critical loop was guarenteed to stay determinisitic.
Since then the Timed Loop was introduced that allowed multiple levels of priority and later allowed us to assign which CPU the code would run on.
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Bluetooth Not Available and Sleep Problem
Please could somebody offer some suggestions for my problem.
I have a similar problem to some posts on this forum. My bluetooth status becomes "not available" after differing amounts of time.
I do not think it is linked with USB devices because it has happened without connecting devices. When this has happened and I close the lid, it turns off the screen but the white on the front stays solid (does not flash). After that, I cannot wake my macbook and have to hold the power to reset.
When it has restarted the bluetooth and sleep work perfectly.
Thanks in advance,
Hdid you read this link yet:
http://discussions.apple.com/thread.jspa?threadID=1172382&tstart=0 -
My computer won't shutdown and sleep
I'm using Windows 8.1 Pro x64 and my computer won't shutdown and sleep. When i try to shutdown pc, everything shutsdown (hdd etc.) but only fans and led's stay on. I have to press power button to shut it down. Even i try to sleep the pc everything shutsdown
but fans and stuff is still on i have to press power button to completely turn it off. I tried to write powercfg -energy code to command prompt and i got 8 errors and 7 warnings. How to solve that problem?
This is what i got:
Power Efficiency Diagnostics Report
Computer Name
DARKORION11
Scan Time
2014-08-13T14:06:49Z
Scan Duration
60 seconds
System Manufacturer
System manufacturer
System Product Name
System Product Name
BIOS Date
03/18/2014
BIOS Version
0805
OS Build
9600
Platform Role
PlatformRoleDesktop
Plugged In
true
Process Count
67
Thread Count
971
Report GUID
{ca7e44e7-3f05-4462-9ce9-72cb0493f6df}
Analysis Results
Errors
System Availability Requests:System Required Request
The program has made a request to prevent the system from automatically entering sleep.
Requesting Process
\Device\HarddiskVolume1\Program Files\Windows Media Player\wmpnetwk.exe
System Availability Requests:System Required Request
The device or driver has made a request to prevent the system from automatically entering sleep.
Driver Name
\FileSystem\srvnet
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
USB Composite Device
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_09DA&PID_90C0
Port Path
1,5
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
USB Root Hub
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_8086&PID_1E26
Port Path
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
Generic USB Hub
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_8087&PID_0024
Port Path
1
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
USB Composite Device
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_09DA&PID_9090
Port Path
1,6
CPU Utilization:Processor utilization is high
The average processor utilization during the trace was high. The system will consume less power when the average processor utilization is very low. Review processor utilization for individual processes to determine which applications and services contribute
the most to total processor utilization.
Average Utilization (%)
6.38
Platform Power Management Capabilities:PCI Express Active-State Power Management (ASPM) Disabled
PCI Express Active-State Power Management (ASPM) has been disabled due to a known incompatibility with the hardware in this computer.
Warnings
Platform Timer Resolution:Platform Timer Resolution
The default platform timer resolution is 15.6ms (15625000ns) and should be used whenever the system is idle. If the timer resolution is increased, processor power management technologies may not be effective. The timer resolution may be increased due to
multimedia playback or graphical animations.
Current Timer Resolution (100ns units)
10005
Maximum Timer Period (100ns units)
156250
Platform Timer Resolution:Outstanding Timer Request
A program or service has requested a timer resolution smaller than the platform maximum timer resolution.
Requested Period
10000
Requesting Process ID
4120
Requesting Process Path
\Device\HarddiskVolume1\Windows\System32\audiodg.exe
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
2428
Average Utilization (%)
1.21
Module
Average Module Utilization (%)
\Program Files (x86)\Google\Chrome\Application\36.0.1985.125\chrome_child.dll
0.96
\SystemRoot\system32\ntoskrnl.exe
0.10
0.03
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
3096
Average Utilization (%)
1.14
Module
Average Module Utilization (%)
\Device\HarddiskVolume1\Program Files (x86)\Google\Chrome\Application\36.0.1985.125\chrome.dll
0.61
\SystemRoot\system32\ntoskrnl.exe
0.20
\SystemRoot\System32\win32k.sys
0.09
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
2956
Average Utilization (%)
0.61
Module
Average Module Utilization (%)
\Device\HarddiskVolume1\Program Files (x86)\Google\Chrome\Application\36.0.1985.125\libglesv2.dll
0.12
\Device\HarddiskVolume1\Windows\SysWOW64\atidxx32.dll
0.12
\Device\HarddiskVolume1\Program Files (x86)\Google\Chrome\Application\36.0.1985.125\chrome_child.dll
0.10
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
4512
Average Utilization (%)
0.45
Module
Average Module Utilization (%)
\Program Files (x86)\Google\Chrome\Application\36.0.1985.125\chrome_child.dll
0.36
\SystemRoot\system32\ntoskrnl.exe
0.04
\SystemRoot\SysWOW64\ntdll.dll
0.01
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
dwm.exe
PID
880
Average Utilization (%)
0.21
Module
Average Module Utilization (%)
\SystemRoot\system32\ntoskrnl.exe
0.04
\Device\HarddiskVolume1\Windows\System32\dwmcore.dll
0.04
\Device\HarddiskVolume1\Windows\System32\atidxx64.dll
0.03
Information
Platform Timer Resolution:Timer Request Stack
The stack of modules responsible for the lowest platform timer setting in this process.
Requested Period
10000
Requesting Process ID
4120
Requesting Process Path
\Device\HarddiskVolume1\Windows\System32\audiodg.exe
Calling Module Stack
\Device\HarddiskVolume1\Windows\System32\ntdll.dll
\Device\HarddiskVolume1\Windows\System32\AudioEng.dll
\Device\HarddiskVolume1\Windows\System32\audiodg.exe
\Device\HarddiskVolume1\Windows\System32\rpcrt4.dll
\Device\HarddiskVolume1\Windows\System32\combase.dll
\Device\HarddiskVolume1\Windows\System32\rpcrt4.dll
\Device\HarddiskVolume1\Windows\System32\ntdll.dll
\Device\HarddiskVolume1\Windows\System32\kernel32.dll
\Device\HarddiskVolume1\Windows\System32\ntdll.dll
Power Policy:Active Power Plan
The current power plan in use
Plan Name
OEM Balanced
Plan GUID
{381b4222-f694-41f0-9685-ff5bb260df2e}
Power Policy:Power Plan Personality (Plugged In)
The personality of the current power plan when the system is plugged in.
Personality
Balanced
Power Policy:802.11 Radio Power Policy is Maximum Performance (Plugged In)
The current power policy for 802.11-compatible wireless network adapters is not configured to use low-power modes.
Power Policy:Video quality (Plugged In)
Enables Windows Media Player to optimize for quality or power savings when playing video.
Quality Mode
Optimize for Video Quality
Battery:Analysis Success
Analysis was successful. No energy efficiency problems were found. No information was returned.
Platform Power Management Capabilities:Supported Sleep States
Sleep states allow the computer to enter low-power modes after a period of inactivity. The S3 sleep state is the default sleep state for Windows platforms. The S3 sleep state consumes only enough power to preserve memory contents and allow the computer
to resume working quickly. Very few platforms support the S1 or S2 Sleep states.
S1 Sleep Supported
false
S2 Sleep Supported
false
S3 Sleep Supported
true
S4 Sleep Supported
true
Platform Power Management Capabilities:Connected Standby Support
Connected standby allows the computer to enter a low-power mode in which it is always on and connected. If supported, connected standby is used instead of system sleep states.
Connected Standby Supported
false
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
0
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
1
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
2
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
3
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Device Drivers:Analysis Success
Analysis was successful. No energy efficiency problems were found. No information was returned.I've just updated my LAN driver and tested again. This is what i got:
Power Efficiency Diagnostics Report
Computer Name
DARKORION11
Scan Time
2014-08-14T09:48:32Z
Scan Duration
60 seconds
System Manufacturer
System manufacturer
System Product Name
System Product Name
BIOS Date
03/18/2014
BIOS Version
0805
OS Build
9600
Platform Role
PlatformRoleDesktop
Plugged In
true
Process Count
77
Thread Count
1286
Report GUID
{25c91f45-b37e-445f-89b7-e2425a6c60f9}
Analysis Results
Errors
Power Policy:Disk idle is disabled (Plugged In)
The disk is not configured to turn off after a period of disk inactivity.
System Availability Requests:System Required Request
The device or driver has made a request to prevent the system from automatically entering sleep.
Requesting Driver Instance
ROOT\MEDIA\0000
Requesting Driver Device
DFX Audio Enhancer 11.1
System Availability Requests:System Required Request
The device or driver has made a request to prevent the system from automatically entering sleep.
Requesting Driver Instance
HDAUDIO\FUNC_01&VEN_10EC&DEV_0887&SUBSYS_10438445&REV_1003\4&3ad857fa&0&0001
Requesting Driver Device
Realtek High Definition Audio
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
USB Root Hub
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_8086&PID_1E26
Port Path
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
Generic USB Hub
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_8087&PID_0024
Port Path
1
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
USB Composite Device
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_09DA&PID_90C0
Port Path
1,5
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
USB Composite Device
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_09DA&PID_9090
Port Path
1,6
USB Suspend:USB Device not Entering Selective Suspend
This device did not enter the USB Selective Suspend state. Processor power management may be prevented when this USB device is not in the Selective Suspend state. Note that this issue will not prevent the system from sleeping.
Device Name
Xbox 360 Controller for Windows
Host Controller ID
PCI\VEN_8086&DEV_1E26
Host Controller Location
PCI bus 0, device 29, function 0
Device ID
USB\VID_046D&PID_C21F
Port Path
1,7
CPU Utilization:Processor utilization is high
The average processor utilization during the trace was high. The system will consume less power when the average processor utilization is very low. Review processor utilization for individual processes to determine which applications and services contribute
the most to total processor utilization.
Average Utilization (%)
8.94
Platform Power Management Capabilities:PCI Express Active-State Power Management (ASPM) Disabled
PCI Express Active-State Power Management (ASPM) has been disabled due to a known incompatibility with the hardware in this computer.
Warnings
Platform Timer Resolution:Platform Timer Resolution
The default platform timer resolution is 15.6ms (15625000ns) and should be used whenever the system is idle. If the timer resolution is increased, processor power management technologies may not be effective. The timer resolution may be increased due to
multimedia playback or graphical animations.
Current Timer Resolution (100ns units)
10005
Maximum Timer Period (100ns units)
156250
Platform Timer Resolution:Outstanding Timer Request
A program or service has requested a timer resolution smaller than the platform maximum timer resolution.
Requested Period
10000
Requesting Process ID
5024
Requesting Process Path
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\chrome.exe
Platform Timer Resolution:Outstanding Timer Request
A program or service has requested a timer resolution smaller than the platform maximum timer resolution.
Requested Period
10000
Requesting Process ID
1120
Requesting Process Path
\Device\HarddiskVolume4\Windows\System32\audiodg.exe
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
4868
Average Utilization (%)
2.39
Module
Average Module Utilization (%)
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\36.0.1985.143\chrome_child.dll
1.97
0.19
\SystemRoot\system32\ntoskrnl.exe
0.11
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
348
Average Utilization (%)
1.07
Module
Average Module Utilization (%)
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\36.0.1985.143\chrome.dll
0.64
\SystemRoot\system32\ntoskrnl.exe
0.17
\SystemRoot\System32\win32k.sys
0.07
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
DFX.exe
PID
1988
Average Utilization (%)
1.02
Module
Average Module Utilization (%)
\Device\HarddiskVolume4\Program Files (x86)\DFX\DFX.exe
0.75
\SystemRoot\system32\ntoskrnl.exe
0.15
\Device\HarddiskVolume4\Windows\SysWOW64\AudioSes.dll
0.02
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
4284
Average Utilization (%)
0.54
Module
Average Module Utilization (%)
0.35
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\36.0.1985.143\chrome_child.dll
0.17
\SystemRoot\system32\ntoskrnl.exe
0.01
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
audiodg.exe
PID
1120
Average Utilization (%)
0.43
Module
Average Module Utilization (%)
\SystemRoot\system32\ntoskrnl.exe
0.13
\Device\HarddiskVolume4\Windows\System32\RltkAPO64.dll
0.09
\Device\HarddiskVolume4\Windows\System32\AudioEng.dll
0.09
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
WWAHost.exe
PID
4840
Average Utilization (%)
0.39
Module
Average Module Utilization (%)
\Device\HarddiskVolume4\Windows\System32\MP3DMOD.DLL
0.20
\Device\HarddiskVolume4\Windows\System32\RESAMPLEDMO.DLL
0.12
\SystemRoot\system32\ntoskrnl.exe
0.00
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
chrome.exe
PID
1944
Average Utilization (%)
0.33
Module
Average Module Utilization (%)
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\36.0.1985.143\libglesv2.dll
0.07
\SystemRoot\system32\ntoskrnl.exe
0.06
\Device\HarddiskVolume4\Windows\SysWOW64\atidxx32.dll
0.06
CPU Utilization:Individual process with significant processor utilization.
This process is responsible for a significant portion of the total processor utilization recorded during the trace.
Process Name
explorer.exe
PID
2972
Average Utilization (%)
0.25
Module
Average Module Utilization (%)
\SystemRoot\system32\ntoskrnl.exe
0.08
\SystemRoot\System32\win32k.sys
0.05
\Device\HarddiskVolume4\Windows\System32\WindowsCodecs.dll
0.04
Information
Platform Timer Resolution:Timer Request Stack
The stack of modules responsible for the lowest platform timer setting in this process.
Requested Period
10000
Requesting Process ID
5024
Requesting Process Path
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\chrome.exe
Calling Module Stack
\Device\HarddiskVolume4\Windows\SysWOW64\ntdll.dll
\Device\HarddiskVolume4\Windows\SysWOW64\kernel32.dll
\Device\HarddiskVolume4\Program Files (x86)\Google\Chrome\Application\36.0.1985.143\chrome_child.dll
\Device\HarddiskVolume4\Windows\SysWOW64\kernel32.dll
\Device\HarddiskVolume4\Windows\SysWOW64\ntdll.dll
Platform Timer Resolution:Timer Request Stack
The stack of modules responsible for the lowest platform timer setting in this process.
Requested Period
10000
Requesting Process ID
1120
Requesting Process Path
\Device\HarddiskVolume4\Windows\System32\audiodg.exe
Calling Module Stack
\Device\HarddiskVolume4\Windows\System32\ntdll.dll
\Device\HarddiskVolume4\Windows\System32\AudioEng.dll
\Device\HarddiskVolume4\Windows\System32\audiodg.exe
\Device\HarddiskVolume4\Windows\System32\rpcrt4.dll
\Device\HarddiskVolume4\Windows\System32\combase.dll
\Device\HarddiskVolume4\Windows\System32\rpcrt4.dll
\Device\HarddiskVolume4\Windows\System32\ntdll.dll
\Device\HarddiskVolume4\Windows\System32\kernel32.dll
\Device\HarddiskVolume4\Windows\System32\ntdll.dll
Power Policy:Active Power Plan
The current power plan in use
Plan Name
OEM Balanced
Plan GUID
{381b4222-f694-41f0-9685-ff5bb260df2e}
Power Policy:Power Plan Personality (Plugged In)
The personality of the current power plan when the system is plugged in.
Personality
Balanced
Power Policy:802.11 Radio Power Policy is Maximum Performance (Plugged In)
The current power policy for 802.11-compatible wireless network adapters is not configured to use low-power modes.
Power Policy:Video quality (Plugged In)
Enables Windows Media Player to optimize for quality or power savings when playing video.
Quality Mode
Optimize for Video Quality
Battery:Analysis Success
Analysis was successful. No energy efficiency problems were found. No information was returned.
Platform Power Management Capabilities:Supported Sleep States
Sleep states allow the computer to enter low-power modes after a period of inactivity. The S3 sleep state is the default sleep state for Windows platforms. The S3 sleep state consumes only enough power to preserve memory contents and allow the computer
to resume working quickly. Very few platforms support the S1 or S2 Sleep states.
S1 Sleep Supported
false
S2 Sleep Supported
false
S3 Sleep Supported
true
S4 Sleep Supported
true
Platform Power Management Capabilities:Connected Standby Support
Connected standby allows the computer to enter a low-power mode in which it is always on and connected. If supported, connected standby is used instead of system sleep states.
Connected Standby Supported
false
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
0
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
1
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
2
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Platform Power Management Capabilities:Processor Power Management Capabilities
Effective processor power management enables the computer to automatically balance performance and energy consumption.
Group
0
Index
3
Idle State Count
3
Idle State Type
ACPI Idle (C) States
Nominal Frequency (MHz)
3301
Maximum Performance Percentage
100
Lowest Performance Percentage
48
Lowest Throttle Percentage
48
Performance Controls Type
ACPI Performance (P) / Throttle (T) States
Device Drivers:Analysis Success
Analysis was successful. No energy efficiency problems were found. No information was returned. -
Java Thread suspend and resume problem
Hi,
I am trying to write a program to implement thread suspend and resume using wait() and notify without using the deprecated methods like resume and suspend.
I have written the following program which compiles but when I run it hangs without terminating. There seems to be some logic error but I am not able to catch it.
Please help
public class TestSuspendResume {
public static void main(String[] args) {
MyThread m1= new MyThread("--One-- ");
MyThread m2= new MyThread("--Two-- ");
m1.suspendMe();
try {
Thread.sleep(1500);
m1.t.join();
m2.t.join();
} catch(InterruptedException e) {
e.printStackTrace();
m1.resumeMe();
System.out.println("Now : end main thread");
class MyThread implements Runnable {
boolean suspend = false;
Thread t;
MyThread(String name) {
t = new Thread(this,name);
t.start();
void resumeMe() {
suspend = false;
notify();
void suspendMe() {
suspend = true;
public void run() {
try {
for(int i=0;i<20;i++) {
System.out.println("Now : "+Thread.currentThread().getName()+i);
Thread.sleep(200);
synchronized(this) {
while(suspend)
wait();
} catch(InterruptedException e) {
e.printStackTrace();
}Thanks for that response. I figured out that was the problem in the logic. I have modified the code to make it simpler but it is still hanging.
public class TestSuspendResume {
public static void main(String[] args) {
MyThread m1= new MyThread("--One-- ");
try {
m1.suspendMe();
Thread.sleep(1000);
} catch(InterruptedException e) {
e.printStackTrace();
try {
m1.resumeMe();
} catch(Exception e) {
System.out.println("ASASAS");
e.printStackTrace();
try {
m1.t.join();
} catch(InterruptedException e) {
System.out.println("WOWOW");
e.printStackTrace();
System.out.println("Now : end main thread");
class MyThread implements Runnable {
boolean suspend = false;
Thread t;
MyThread(String name) {
t = new Thread(this,name);
t.start();
void resumeMe() {
if(suspend==true) {
suspend = false;
notify();
void suspendMe() {
suspend = true;
public void run() {
try {
for(int i=0;i<20;i++) {
System.out.println("Now : "+Thread.currentThread().getName()+i);
Thread.sleep(200);
synchronized(this) {
while(suspend)
wait();
} catch(InterruptedException e) {
System.out.println("-- E In run method -- "+e.getMessage());
} -
Hi
I have an array that keeps Integer into it. what is wrong with this problem i cant fix it. Thread Consumer never start.
Producer class: Putting nr 1 to 50 int into array eg. 1-2-3-4-5-6-7-8-9-10.....
Consumer class : removing 50 down to nr 10 from array 50-49-48-47...
Main Class : Threads creator and starter.
How can i let Thread P start before C. and when P is finnish it call C, and then C when its done it wakes up P and running like that for life. HOWWW Plz help
MAIN CLASS:
import java.util.ArrayList;
public class Main {
static ArrayList<Integer> list = new ArrayList<>();
public static void main(String[] args) {
Thread p = new Thread(new Producer());
Thread c = new Thread(new Consumer());
p.start();
c.start();
PRODUCER CLASS:
public class Producer extends Main implements Runnable{
@Override
public void run() {
while (true) {
// Tilføjer cornflakes til arrayListen hvis < 10
if (list.size() <= 10) {
for (int i = list.size(); i < 50; i++) {
list.add(i);
System.out.println("p : " + list.size());
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}// end Forloop
}// end if
}// end while
Consumer CLASS
public class Consumer extends Main implements Runnable {
@Override
public synchronized void run() {
while (true) {
// Tilføjer cornflakes til arrayListen hvis < 10
for (int i = list.size(); i > 10; i--) {
list.remove(i);
System.out.println("c : " + i);
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}// end Forloop
}// end while
}That's a reason for failure in general by the way - trying to do stuff without understanding stuff. Its best avoided in the future - first learn and learn well, then code. Then when you have problem with said code, come here and ask for help. Not before that, a forum is not a personal information service or substitute teacher.
-
Make a Thread to get sleep for a time that has decimals
I need a Thread to get sleep for a time that has decimals, for example 3,5 miliseconds but is not possible because the Thread.sleep() admits only long. Is not other way to do it?
Thanksdannyyates wrote:
Well, there's sleep(long millis, int nanos), but to be honest if you're requirements are that tight, sleep() is probably not the right tool for you because if doesn't really guarantee any level of accuracy.That's true, the accuracy of sleep() depends rather on the underlying OS and hardware. As the docs say:
"Causes the currently executing thread to sleep (temporarily cease execution) for the specified number of milliseconds, *subject to the precision and accuracy of system timers and schedulers*. "
Just run this simple test program, it gives interesting results:
long start, stop;
for (int i=0; i<100; i++) {
start = System.nanoTime();
try {
Thread.sleep(5);
} catch (InterruptedException e) {
e.printStackTrace();
stop = System.nanoTime();
System.out.println("The thread slept for " + (stop-start)/1000000.0 + " ms");
}On my Windows XP with dual core CPU I get:
The thread slept for 5.801576 ms
The thread slept for 5.778108 ms
The thread slept for 6.134019 ms
The thread slept for 5.437562 ms
The thread slept for 6.064458 ms
The thread slept for 5.674744 ms
The thread slept for 15.354466 ms
The thread slept for 5.869461 ms
The thread slept for 5.785372 ms
The thread slept for 5.804649 ms
If you really need a precise timer you need either a real-time OS or a different solution, the method sleep(millis, nanos) will solve the problem without proper OS/hardware -
Multithreading and sleep()
I have multiple thread running and they all have equal priorities. They must run alternately in a periodic manner. I call sleep() method so as other threads would run.
My question is:
Thread 1 is running then reaches its sleep(1000) so lets say Thread 2 starts running. Then while Thread 2 is running, Thread 1's sleep() returns. Would this result Thread 1 to run again at once and leave Thread 2 hanging even before Thread 2 reaches its own sleep()?
Need help on this. Thank you very much!Threads coming out of sleep() do not "wake" other Threads up. In fact, even the time spent in sleep() is not guarenteed. To do what you need you must construct a concurrent structure that is capable of alternating threads. This can be done with two "CyclicBarriers". That code and everything else you need to know about concurrent programming before you mess up is in this book.
http://java.sun.com/docs/books/cp/ -
Difference between wait() and sleep()
hi
can any one tell me what is the difference between wait() and sleep().
thanks in advance.Mahaboob,
This question has been asked before; however, I will give you a real life example.
Imagine you are in a super market and you go to the till to pay by your card, then behind you there are 10 people waiting in queue. You card does not work since you have not supplied the right pin code; there are two option
1- Sleep
2- Wait
1- If you sleep you will lock the till for your self and try to figure out the pin number while the queue behind you increase on the resource (till)
so you are engaging the till and wasting its time and wasting the till machine resource (CPU)
2- you are polite, you move aside and wait so so that others can use the resource (till) until somebody in the queue finishes ( a good person) and give you a shout to tell you come in to the till to process your payment; you wake up and enter the pin number and go out from the super market.
Now when you sleep, the current thread locks the resource so no body can use it and wast the CPU time
while wait make the current thread release the lock on the object and does not ( this thread) actually wast the CPU time
There are much more explanantion, try to search this forum.
Regards,
Alan Mehio
London,UK
Maybe you are looking for
-
Using XSLT mapping to avoid File content conversion
Hi all, Can we avoid FCC by using XSLT mapping? I have a scenario in which I have to avoid FCC in the adapter and save the file in a excel/csv format. I have been through the different blogs and forums in SDN. I have been through Michal Krawczyk's Bl
-
I am in dire need of assistance...
It seems on my Ipod, that when I'm listening to it, audio only seems to come out of one ear on my ear phones... I figured something was wrong with my ear phones, so I bought new ones and it still was presenting the same problem. I then began to mess
-
JDK 1.4.2_10; problem with applet/classpath/OBJECT tag
I'm supporting an applet that needs to run in JDK 1.4.2_10 in order to work. (I don't own the code, so I can't fix the issue) I'd like to force that particular applet to run under JDK 1.4.2_10, but allow other applets to run on the current default JV
-
Change pointer entries not updated in BDCP table
I am using a IDOC to file senario.For message type ISM_MATMAS. In Tcode JP28 when changing Business partner only CDHDR and CDPOS table are getting updated but BDCP table is not getting updated. I have activated CP's for message type in Tcode BD50, Gl
-
Document raster effect settings and Gradient mesh resolution settings...
Hi, I need to set Document raster effect settings and Gradient mesh settings as high resolution in Illustrator 10.. Dont no which header file and suites have to use? How can i get and set the value of both Document raster effect setti