可能重複霸佔CPU APRT:
simulate cpu usage in mono for Android是thereany其他辦法從線程
是否有使用更多的CPU,而不是在單/ Android應用程序線程任何其他方式? 請給出一些建議。
謝謝,
可能重複霸佔CPU APRT:
simulate cpu usage in mono for Android是thereany其他辦法從線程
是否有使用更多的CPU,而不是在單/ Android應用程序線程任何其他方式? 請給出一些建議。
謝謝,
不知道什麼章節目標是服務,但是這不使用任何輔助線程,並會吸取CPU相當不錯:
[Activity(MainLauncher = true)]
public class PointlessActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
while(true) { }
}
}
這將加載一個線程。因此,在多核Android設備上運行此操作只會加載1個/內核。 – Cheesebaron
是的,但OP的「無線程」要求非常有限。對於任何你沒有線程的嘗試,情況也是如此。 – ctacke
您可以實現一個帆布其中像這樣每次無效:
private class Painter extends View{
ArrayList<Point> points;
public Painter(Context context){
super(context);
}
public void draw() {
points = new ArrayList<Point();
for (int i = 0; i < 10000; i++) {
//assign Points to the array
Point p = new Point();
p.x = 10;
p.y = 30;
points.add(p);
}
nameOfTheInstancePainter.invalidate();
}
@Override
protected void onDraw(Canvas c) {
for (int i = 0; i < 10000; i++) {
//paint aaaall the points
}
nameOfTheInstancePainter.invalidate(); //that will cause the ReDraw of everything everytime
}
}
哦,順便說一句,繪畫畫布使用不同的線程,這就是爲什麼我這樣做的代碼!
編號繪製畫布使用主程序運行的相同UI線程。 – DeeV
真的嗎?我一生都在撒謊@。@無論如何,這將是非常密集的,但這不是他正在尋找的東西 –
是否有任何理由爲什麼你沒有更新你現有的線程? http://stackoverflow.com/questions/10910663/simulate-cpu-usage-in-mono-for-android – Cheesebaron