If a class has these two methods:  public static synchronized void m1() {}  public synchronized void m2() {}  Can two threads execute these two methods at the same time?
55847
The Java documentation says:      It is not possible for two invocations of synchronized methods on the   same object to interleave.   What does this mean for a static method?  Since a static method has no associated object, will the synchronized keyword lock on the class, instead of the object?
102708
Is it possible, to execute a class in a specified directory?  I mean, a.class is in directory abc and i want it to be executed as if it were in directory xyz.
65261
What are some real world places that call for delegates?  I'm curious what situations or patterns are present where this method is the best solution.  No code required.
66447
I have an object with a method named StartDownload(), that starts three threads.  How do I get a notification when each thread has finished executing?  Is there a way to know if one (or all) of the thread is finished or is still executing?
3385
In the two following snippets, is the first one safe or must you do the second one?  By safe I mean is each thread guaranteed to call the method on the Foo from the same loop iteration in which the thread was created?  Or must you copy the reference to a new variable "local" to each iteration of the loop?  var threads = new List&lt;Thread&gt;(); foreach (Foo f in ListOfFoo) {           Thread thread = new Thread(() =&gt; f.DoSomething());     threads.Add(thread);     thread.Start(); }   -  var threads = new List&lt;Thread&gt;(); foreach (Foo f in ListOfFoo) {           Foo f2 = f;     Thread thread = new Thread(() =&gt; f2.DoSomething());     threads.Add(thread);     thread.Start(); }   Update: As pointed out in Jon Skeet's answer, this doesn't have anything specifically to do with threading.
45337
I'm making a Java application with an application-logic-thread and a database-access-thread. Both of them persist for the entire lifetime of the application and both need to be running at the same time (one talks to the server, one talks to the user; when the app is fully started, I need both of them to work).  However, on startup, I need to make sure that initially the app thread waits until the db thread is ready (currently determined by polling a custom method dbthread.isReady()). I wouldn't mind if app thread blocks until the db thread was ready.  Thread.join() doesn't look like a solution - the db thread only exits at app shutdown.  while (!dbthread.isReady()) {} kind of works, but the empty loop consumes a lot of processor cycles.  Any other ideas? Thanks.
14981
Can any one tell me the advantage of synchronized method over synchronized block with an example?
42496
I have a method which should be delayed running for a specified amount of time.  Should I use  Thread thread = new Thread(() =&gt; {     Thread.Sleep(millisecond);     action(); }); thread.IsBackground = true; thread.Start();   Or  Timer timer = new Timer(o =&gt; action(), null, millisecond, -1);   I had read some  about using Thread.Sleep is bad design. But I don't really understand why.  But for using Timer, Timer has dispose method. Since the execution is delayed, I don't know how to dispose Timer. Do you have any suggestions?  Or if you have alternative codes for delayed execution are also appreciate.
50500
A curious thing happens in Java when you use an abstract class to implement an interface: some of the interface's methods can be completely missing (i.e. neither an abstract declaration or an actual implementation is present), but the compiler does not complain.  For example, given the interface:  public interface IAnything {   void m1();   void m2();   void m3(); }   the following abstract class gets merrily compiled without a warning or an error:  public abstract class AbstractThing implements IAnything {   public void m1() {}   public void m3() {} }   Can you explain why?
44510
Can someone post a simple example of starting two (Object Oriented) threads in C++.   I'm looking for actual C++ thread objects that I can extend run methods on (or something similar) as opposed to calling a C-style thread library.  I left out any OS specific requests in the hopes that whoever replied would reply with cross platform libraries to use. I'm just making that explicit now.
95908
I came across  article discussing why the double-check locking paradigm is broken in Java. Is the paradigm valid for .NET (in particular, C#), if variables are declared volatile?
68648
Let's say that you have overridden an object's equals() and hashCode() methods, so that they use the object's fields.  How you do you check if two references are to the same object, ala the stock equals() method?
108141
I'm relatively new to Threading in Java and I've noticed that everytime I use Thread.sleep() I have to catch InterrupetdException.  What kind of behaviour causes this, and in simple applications where I have a monitor thread can I just Ignore the exception?
13645
What real (i.e. practical) difference exists between a static class and a singleton pattern?  Both can be invoked without instantiation, both provide only one "Instance" and neither of them is thread-safe. Is there any other difference?
19425
global class ScheduleBatch implements Schedulable {      global void execute(SchedulableContext sc) {       BatchArticleUpdateCase batch = new BatchArticleUpdateCase();        database.executebatch(batch);     }     Public static void SchedulerMethod(){      } }
49826
I've been trying to wrap my head around how threads work in Python, and it's hard to find good information on how they operate. I may just be missing a link or something, but it seems like the official documentation isn't very thorough on the subject, and I haven't been able to find a good write-up.  From what I can tell, only one thread can be running at once, and the active thread switches every 10 instructions or so?  Where is there a good explanation, or can you provide one? It would also be very nice to be aware of common problems that you run into while using threads with Python.
67272
Is it safe to fork off a Thread to execute an insert using a JdbcTemplate in Swing.  It's a logging event and as much as possible I don't want it to affect perceived performance.