문제는 복잡하지만, 내가하고 싶은 것을 먹으 렴 :통화 방법
public class Main
{
MyClass instance = new MyClass();
Thread secondThread = new Thread(instance);
public static void main()
{
secondThread.start();
//here i want to call foo(), but be processed by secondThread thread(not the Main thread)
}
}
public class MyClass implements Runnable
{
@Override
public void run()
{
}
public void foo()
{
System.out.println("foo");
}
}
을 내가 사용하는 경우 "instance.foo를();" 그것은 메인 스레드에 의해 처리됩니다.
예, 나는 이미 그것에서 실행 해요 .. –