.net - when a method is called , which thread will be run in c# and java? -


everybody knows using multi threading platforms , developing multi threading applications. way, couldn't recognize thread issue. when call static method (that in class.) , thread run ? gui thread go jobs , run method ? i.e: (i gonna give vb code sample . logic same java.)

private sub runvaluestest_click(sender system.object, e system.eventargs) handles runvaluestest.click    dummyclass.instance.dojob() end sub() 

this vb syntax not matter . main logic same c# , java. when click button, new thread run ? or gui thread go job ?

if new thread run, why , when use new thread our jobs ?

if gui thread goes, see lots of time more 1 thread run in program. how can threads different in program? why , when thread exceptions occurs somehow ? example: doing file operation in method: (this may different question)

private _file system.io.streamwriter private sub runvaluestest_click(sender system.object, e system.eventargs) handles runvaluestest.click     if not directory.exists("graphxml")         directory.createdirectory("graphxml")     end if      _filename = "graphxml\graph_" & txtname & ".xml"      _file = my.computer.filesystem.opentextfilewriter(_filename, false)      _file.writeline("<?xml version=""1.0"" encoding=""utf-8""?>")      _file.writeline("<n0>")      depthfirstsearch(staticservice.allnodes(0))      _file.writeline("</n0>")     _file.close()     _file.dispose()  end sub 

when click fast (1 click per 2 seconds) , gives error "another process uses file".

if gui thread , why give error ?

if new thread , why staffs gui operations in button click method. ? (everybody knows , gui operations , want use gui thread, right?)

this second code part may different question want learn logic behind of thread .net ( think logic valid java)

thanks

edit: may not relevant java. although give vb code sample, added java tag because think logic same.

when call static method (that in class.) , thread run ?

you don't call methods. write code. threads call methods. thread agent executes code. every program has @ least 1 thread. when thread calls method (static or not), method called in thread called it.

when click button, new thread run ? or gui thread go job ?

that question visual basic. don't know visual basic, many gui frameworks have "event handler thread". when click button, event read framework code running in event handler thread. framework figures out window, widget, etc., , if code has registered handler, event handler thread calls handler method.

to gui operations , want use gui thread, right?)

there powerful reason why many gui frameworks single threaded. https://weblogs.java.net/blog/kgh/archive/2004/10/multithreaded_t.html again, if asking visual basic, that's wouldn't know about.

how can threads different in program?

why , when thread exceptions occurs somehow ?

...?

you either need learn more english before try asking questions in english, or need learn more threads (work through tutorials) before try asking questions threads. lot of questions don't seem make sense.


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -

php - $params->set Array between square bracket -