Wikipedia:Reference desk/Archives/Computing/2013 May 5

From Wikipedia, the free encyclopedia
Computing desk
< May 4 << Apr | May | Jun >> May 6 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


May 5[edit]

Copying a CD via iTunes[edit]

Probably a silly question, but something that's puzzled me for a while. When copying tracks from a CD to a computer hard drive using iTunes (and presumably with other similar software) I often notice that the first few tracks copy slowly, but the rate of copying speeds up as the CD nears the end. The first few tracks may copy at 12x playing speed, say, but by the last track it'sll be copying at around 20x. Presumably there's some technical reason for this... but what? Thanks in advance, Grutness...wha? 03:52, 5 May 2013 (UTC)[reply]

I don't know, but perhaps the fact that CDs write from the inside out, and the outside of the disc spins faster? Is there any references for this theory? Mingmingla (talk) 04:00, 5 May 2013 (UTC)[reply]
I have no source, but yes, it's because the data is written in a spiral starting from the inner edge at a constant linear density, and the bottleneck is not the decoding but the angular speed of the disc, which has to be limited to avoid noise, vibration, and shattered CDs. -- BenRG 04:15, 5 May 2013 (UTC)
Makes sense - thanks for that. Grutness...wha? 12:27, 6 May 2013 (UTC)[reply]

What is The use of Thread class constructors?[edit]

Hi!My doubt is on Thread class constructors
1)public Thread()
2)public Thread(String name)
The above two are two constructors of thread class.
First constructor is used to create object of thread class.
Second constructor is also used to create object of thread class with required name.
If we write
1)Thread t1=new Thread();
This creates a thread class object t1.
2)Thread t2=newThread(“MYTHREAD”);
This also creates Thread class object t2 .It also creates thread with name "MYTHREAD".
My questions are
1)What is the benefit of above t1,t2;
2)How can we use the thread class objects t1,t2?
3)Is it possible to execute run method of the thread "MYMTHREAD"?
4)Suppose we have extended class named “a” from Thread class like below.
Then how can we use t1,t2 on below class “a”?
Is it possible to create thread to below class “a” with required name by using above constructors?

Class  a  extends Thread  
{  
Public void run()  
{  
System.out.println(“Hi”);  
}  
}

--Me shankara (talk) 05:16, 5 May 2013 (UTC)shankara[reply]

Threads have names only for debugging purposes (urgh, maybe serialization too, but doing that is a bit naff). You can't (natively) getThreadByName. A thread implementation could chose to mark the native thread with the name (if the OS supported that), so thread names showed up as something more informative than "java" when viewed with native debug and trace tools(e.g. top, pstree, ps); although that mechanism exists on Linux (via prctl), it looks like the OpenJDK thread implementation at least doesn't use it (I've not tried other OSes or other Java runtimes). So with that, all you can do with a thread name is print it, when you have a handle to the Thread object. This is still pretty handy - run the program below and you'll see that the thread name helps clarify which threads are "ours" and which are utility things that the runtime itself created:
import java.util.Map;

public class SleepyThreads implements Runnable {
    public static void snooze(int ms){
    	try {
            Thread.sleep(ms);
        }
	catch (InterruptedException e) {}
    }

    static final int THREAD_COUNT=5;
    static volatile boolean keep_running=true;

    public static final void main(String [] args) {
        Thread [] slaves = new Thread[THREAD_COUNT];
        for(int i=0; i< THREAD_COUNT; i++){
            slaves[i] = new Thread(new SleepyThreads(), "SleepyThread("+Integer.toString(i)+")");
            slaves[i].start();
        }

	snooze(5*1000);

        Map<Thread,StackTraceElement[]> m = Thread.getAllStackTraces();

        keep_running=false; // makes all the slaves quit                                                            
        snooze(100); // wait a bit, so the slaves dying prints don't mess up with later prints                      

        for (Map.Entry<Thread,StackTraceElement[]> entry: m.entrySet()){
            System.out.println("\n---" + entry.getKey());
            for(StackTraceElement e: entry.getValue()) {
                System.out.println("   " + e);
            }
        }
    }

    public void run() {
        while(SleepyThreads.keep_running){
            System.out.println("name:" + Thread.currentThread().getName());
            snooze((int)Math.random()*500);
        }
    }
}
-- Finlay McWalterTalk 11:57, 5 May 2013 (UTC)[reply]
Re #4: constructors are not inherited in Java, so your class a has merely the default constructor, which calls the default Thread constructor. If you want to invoke some other constructor of a superclass, you must write one or more constructors in the subclass that forward to it. --Tardis (talk) 02:40, 8 May 2013 (UTC)[reply]

WINDOWS 7 - HIDDEN FUNCTIONS[edit]

Are there any more hidden functions in windows 7 other than sticky notes, sound recorder and snipping tool? thank you.175.157.233.231 (talk) 12:41, 5 May 2013 (UTC)[reply]

What's "hidden" about sticky notes or sound recorder? They're both right there in the Accessories menu. -- Finlay McWalterTalk 13:04, 5 May 2013 (UTC)[reply]
So is Snipping Tool according to [1]. I guess the real question is "Which Windows 7 functions haven't I discovered?" That's hard to guess for others. PrimeHunter (talk) 13:51, 5 May 2013 (UTC)[reply]
You may wish to start by looking at Features new to Windows 7 (and, if you previously used XP rather than Vista, Features new to Windows Vista too). Thanks, davidprior t/c 16:09, 5 May 2013 (UTC)[reply]
Also, (at least in Vista - probably in 7 too) the "System Tools" folder is contained within the Accessories folder - which includes the all-important Disk Defragmenter and some other stuff too. If you explore the "All Programs" menu for a while, you never know what you'll discover; honestly! :) --Yellow1996 (talk) 17:02, 5 May 2013 (UTC)[reply]
This is my favourite: Windows Master Control Panel shortcut Vespine (talk) 03:44, 6 May 2013 (UTC)[reply]

Battery life and charging[edit]

All rechargable batteries, no matter what device they are in, are doomed to die, right? Well I've heard conflicting stories as to the proper practices for taking care of these batteries (ie. don't recharge unless it is close to 0% etc.) The two devices I am most concerned about are my laptop (a Toshiba Satellite from 2008) and my PSP. I usually have my laptop plugged in whenever I use it, so it's always at 100%. My PSP, on the other hand, I only charge when it has gotten very low. Are these the right things to do? Am I unknowingly damaging/shortening the lives of the batteries by doing these things? Any information is greatly appreciated. Thanks! --Yellow1996 (talk) 16:55, 5 May 2013 (UTC)[reply]

See Wikipedia:Reference desk/Archives/Computing/2013 January 30#Rechargeable power sources for electronic devices. Shadowjams (talk) 17:16, 5 May 2013 (UTC)[reply]
Wirbelwind has a good answer in there. Shadowjams (talk) 17:17, 5 May 2013 (UTC)[reply]
Thanks, Shadowjams. Oddly enough, I remember reading that exact thread! :) To quote BatteryUniversity: "once the lithium-ion battery is full the charger discontinues charge and only engages when the battery voltage drops. Most users do not remove the AC power [from their laptops] and I like to believe that this practice is safe." And it looks as though waiting for the power to go down close to 0% for my PSP is the right thing to do. Thanks again! --Yellow1996 (talk) 18:02, 5 May 2013 (UTC)[reply]
No problem! It suggested that with a li-ion battery there was no need to ever fully discharge it (unlike some old nicd batteries), and keeping a li-ion near 0% is dangerous cause it could kill it (0% on the readout is not actually 0%; li-ions left at low voltage will eventually die because the over-charge circuitry draws a small amount of current, and if it ever hits zero it's really screwed). Shadowjams (talk) 19:38, 5 May 2013 (UTC)[reply]
Okay, So I just have to make sure I recharge my PSP right away when it is low? I'll definitely do that. Thank you for clearing all this up! :) --Yellow1996 (talk) 22:24, 5 May 2013 (UTC)[reply]
For modern consumer batteries, any charging pattern is safe. The worst thing you can do is leave the battery unused for a long time at 0%, and even that isn't dangerous—it will just make the battery permanently unusable. But I think your original question was about lifetime, and you can increase the lifetime by, among other things, keeping the charge level away from "100%" (~4.2 V) as much as possible. See this article, for example. -- BenRG 22:05, 8 May 2013 (UTC)
Thanks for the extra information! :) My laptop is getting old, so battery life concervation isn't really a concern for me anymore; however I will apply that knowledge to other devices I have and will have in the future. Thanks again, everyone! --Yellow1996 (talk) 01:21, 9 May 2013 (UTC)[reply]

Windows XP shutdown[edit]

Is it possible to configure XP so that it displayes the old 3.1 "It is now safe to turn off your computer" screen on shutdown, rather than switching off the power automatically? Tevildo (talk) 22:16, 5 May 2013 (UTC)[reply]

I never used Windows 3.1 but apparently "It is Now Safe to Turn Off Your Computer" is an error message in Windows XP and 2000. Though maybe another user knows of a way to change the display. --Yellow1996 (talk) 22:29, 5 May 2013 (UTC)[reply]
According to that article, disabling "Advanced Power Management Support" should produce the message 77.101.52.130 (talk) 22:38, 5 May 2013 (UTC)[reply]
Thanks for the information. It seems that I'd need to re-flash the BIOS and do a complete reinstall of XP - not really worth the effort, I think. Tevildo (talk) 16:39, 6 May 2013 (UTC)[reply]
I don't think that's true. You just need to disable advanced power management as described in the article (just uncheck "Enable APM" instead of checking it). Though I don't understand why you want to do this. -- BenRG 20:59, 7 May 2013 (UTC)
I don't have that tab available, as the system I wanted to change has ACPI rather than APM. To change from ACPI to "Standard PC" means disabling ACPI in the BIOS and re-installing Windows. It's not possible to disable ACPI in the standard BIOS setup, only with a special development build that requires re-flashing. But thanks again for putting me on the track to discover this. Tevildo (talk) 22:13, 7 May 2013 (UTC)[reply]
Oh, as for why I want to do this, the system power supply isn't ATX-compliant - it can only be switched off using the mains switch. So when the system shuts down, it's a question of hitting the mains switch after XP has stopped but before it starts rebooting. Not a serious problem (compared with the BIOS reconfiguration). Tevildo (talk) 22:18, 7 May 2013 (UTC)[reply]
You can edit the Windows boot menu so that it waits for confirmation before starting as normal, or set the timeout to say, 120 seconds, so you have plenty of time to turn it off at this point. CS Miller (talk) 19:29, 9 May 2013 (UTC)[reply]
That sounds as though it would get round the problem. How do I set this up? Tevildo (talk) 17:30, 10 May 2013 (UTC)[reply]